Group,
I'm stuggling to get values from an sql database table into several textboxes. I'm not getting an error, but I'm also not getting anything to show up in these textboxes. Can you offer some thoughts as to what I need to do to fix this?
Private Sub btnUpdateOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateOrder.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim string1 As String = txbPartNo.Text.Trim
Dim search1 As String = "'" & string1 & "'"
Try
con.ConnectionString = ("Data Source=DON-PC;Initial Catalog=DataDesignSolutions;Integrated Security = True;User ID=DON-PC;Password=be67011;")
cmd.Connection = con
cmd.CommandText = "SELECT [INV-DESCRIPTION], [INV-UNIT-MEASURE], [INV-SELL-PRICE-1] FROM INVENTORY WHERE [INV-PART-NUMBER] LIKE " & search1
con.Open()
Dim rdr As SqlDataReader = cmd.ExecuteReader
While rdr.Read()
txbDesc.Text = Convert.ToString(rdr("[INV-DESCRIPTION]"))
txbUM.Text = Convert.ToString(rdr("[INV-UNIT-MEASURE]"))
txbPrice.Text = Convert.ToString(rdr("INV-SELL-PRICE-1"))
rdr.Close()
End While
Catch ex As Exception
MessageBox.Show("Error while retrieving records on table..." & ex.Message, "Load Records")
Finally
con.Close()
End Try
End Sub
Thanks for your assistance,
Don