I didn't get the result I want from the following code:
Private Sub tblView_SelectionChanged(ByVal sender As System.oject, ByVal e as System.EventArgs)Handles tblView.SelectionChanged Dim st As String = tblView.SelectedRows.ToString txtID.Text = st(0) Try myCommand = New SqlCommand("SELECT * FROM tblRack WHERE RackID = "& txtID.Text &"", myConnection) myReader = myCommand.ExecuteReader() While myReader.Read txtID.Text = myReader(0).ToString txtRack.Text = myReader(1).ToString End While myReader.Close() Catch ex As Exception MsgBox (ex.Message) End Try End Sub I wanted the data I selected on the datagridview row to be display in the textbox, but it displays the error message that st(0) produces "S" which is incompatible to my RackID data type. Any idea?