Hi,
I am brand new to using SQL with VB. I am trying to be able to insert data from any given row in my SQL table. The row to be inserted is selected by the user on a listbox on Form1. Here is my code:
Imports System.Data.SqlServerCe
Public Class Edit_Sensor_Form
' Shared variables
Dim con As SqlCeConnection = New SqlCeConnection("Data Source=C:\Users\Bryan\documents\visual studio 2010\Projects\SiteSecure v1.1\SiteSecure v1.1\Database1.sdf")
Dim myDA As SqlCeDataAdapter
Dim myDataSet As DataSet
Dim DataGridView1 As DataGrid
Dim ret As SqlCeDataReader
Dim mySelectQuery As String = "Select * FROM Sensor_Table"
Dim SelectedIndex As Integer
Private Sub Edit_Sensor_Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SelectedIndex = My.Forms.Form1.ListBox1.SelectedIndex
Dim cmd As New SqlCeCommand(mySelectQuery, con)
con.Open()
myDA.SelectCommand = cmd
myDA.Fill(myDataSet)
TextBox1.Text = myDataSet.Tables(0).Rows(SelectedIndex).Item("Equipment_ID").ToString
End Sub
End Class
I believe my code is getting hung up at "myDA.SelectCommand = cmd". TextBox1.Text is empty (blank) when I execute my code. Can anyone please shed some light on this?