Is there a problem with my code? i'm trying to refresh a few form checkboxes based on text typed into machinetxt.text with what is currently stored in the database. i put this into the refresh button click event. here is my code:
Private Sub machinerefreshbutton_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles machinerefreshbutton.Click
Dim mycon As SqlCeConnection
Dim mycmd As New SqlCeCommand
Dim myDA As New SqlCeDataAdapter
Dim myDS As New DataSet
Dim myDT As New DataTable
If machinetxt.Text <> "" Then
Try
mycon = GetConnect()
mycon.Open()
mycmd = mycon.CreateCommand
mycmd.CommandText = "SELECT * FROM machine WHERE Machine='[" & machinetxt.Text & "] ' "
myDA.SelectCommand = mycmd
myDA.Fill(myDS, "machine")
myDT = myDS.Tables("machine")
If (myDT.Rows.Count > 0) Then
line1check.CheckState = "[Line 1]"
line2check.CheckState = "[Line 2]"
line3check.CheckState = "[Line 3]"
line4check.CheckState = "[Line 4]"
line5check.CheckState = "[Line 5]"
line6check.CheckState = "[Line 6]"
line7check.CheckState = "[Line 7]"
line8check.CheckState = "[Line 8]"
line9check.CheckState = "[Line 9]"
line10check.CheckState = "[Line 10]"
line11check.CheckState = "[Line 11]"
utilitiescheck.CheckState = "[Utilities]"
misccheck.CheckState = "[Miscellaneous]"
smokehousecheck.CheckState = "[Smoke House]"
Else
MsgBox("Machine " & Trim(machinetxt.Text) & " not found in database.", MsgBoxStyle.OkOnly)
End If
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error!!")
End Try
End If
End Sub
Does anyone see a problem with it? i've tried tweaking the select statement but it still gives the error that the machinetxt.text string is not found in the database. Even though i type it in exactly as shown in the database.
Any help would be appreciated. Thanks