i want to input a data from textbox1 (ex: NSB1000-PCP) and when i click textbox2 i want to display the corresponding value of PCP which is PENTAX. i was unable to get that data from sql to display in textbox2? what's wrong with the code? (PCP = abbrev; PENTAX = comp)
Dim conn As SqlConnection Dim adapter As New SqlDataAdapter Dim connecting As String Dim reader As SqlDataReader
connecting = "Data Source = ERIK\SQLEXPRESS; Integrated Security = True; database = NSB1"
conn = New SqlConnection(connecting)
Dim text1 As String = TextBox1.Text
Dim words() As String
Dim separator() As String = {"-"}
words = text1.Split(separator, StringSplitOptions.RemoveEmptyEntries)
Try
conn.Open()
Dim Query As String = words(1)
Query = "select comp from list where abbrev = '" & TextBox1.Text & "' "
COMMAND = New SqlCommand(Query, conn)
reader = COMMAND.ExecuteReader
Dim dt As New DataTable
While reader.Read
TextBox2.Text = reader("comp")
End While
conn.Close()
Catch ex As Exception
End Try
Aucun commentaire:
Enregistrer un commentaire