I'm using a data reader for basically a read only form. I have a textbox where a user would enter a number, then the reader goes out and finds that record and updates the form.
the first record returns fine but when I go to enter a different number in the textbox to go out and find another record, the form doesn't refresh with the new data. I don't get any errors so I'm assuming it found the record. why does the form refresh ?
below is my code.
any help would be appreciated.
sqlCnn = New SqlConnection(connetionString)
Try
sqlCnn.Open()
sqlCmd = New SqlCommand(sql, sqlCnn)
Dim sqlReader As SqlDataReader = sqlCmd.ExecuteReader()
While sqlReader.Read()
Label5.Text = sqlReader("field1") & ""
Label6.Text = sqlReader("field2") & ""
Label7.Text = sqlReader("field3") & ""
Label8.Text = sqlReader("field4") & ""
End While
sqlReader.Close()
sqlCmd.Dispose()
sqlCnn.Close()
Catch ex As Exception
MsgBox("Error in Dataset !")
End Try
the first record returns fine but when I go to enter a different number in the textbox to go out and find another record, the form doesn't refresh with the new data. I don't get any errors so I'm assuming it found the record. why does the form refresh ?
below is my code.
any help would be appreciated.
sqlCnn = New SqlConnection(connetionString)
Try
sqlCnn.Open()
sqlCmd = New SqlCommand(sql, sqlCnn)
Dim sqlReader As SqlDataReader = sqlCmd.ExecuteReader()
While sqlReader.Read()
Label5.Text = sqlReader("field1") & ""
Label6.Text = sqlReader("field2") & ""
Label7.Text = sqlReader("field3") & ""
Label8.Text = sqlReader("field4") & ""
End While
sqlReader.Close()
sqlCmd.Dispose()
sqlCnn.Close()
Catch ex As Exception
MsgBox("Error in Dataset !")
End Try