'here's your code
If IsNumeric(txtSearchCase.Text) Then
search = "SELECT * FROM CapRec WHERE CaseNumber LIKE '%" & txtSearchCase.Text & "%';"
'txtCaseNum.Text = drSqlDataReader1.Item(0)
Else
search = "SELECT * FROM CapRec WHERE LastName LIKE '%" & txtSearchCase.Text & "%';"
End If
Dim SqlConnection1 As New SqlConnection(myConnectionString)
Dim SqlCommand1 As New SqlCommand
Dim dr As SqlDataReader
SqlCommand1.Connection = SqlConnection1
SqlCommand1.CommandText = search
SqlCommand1.CommandType = CommandType.Text
'open the data connection
SqlConnection1.Open
'assign the results of SqlCommand1's execute reader method to the datareader
dr= SqlCommand1.ExecuteReader()
'I always test for rows
If dr.HasRows Then
'the following line will keep executing the Read method as long as there is more records to read
While dr.Read
'FieldCount returns how many columns are in the current row
'I'm just using it here to dump your returned data to the
'console window
For i As Integer = 0 to dr.FieldCount-1
'Here I am testing for DbNull.Value, making sure there is actual
'data in the specific column index for the current record
' and writing the values to the Visual Studio Output window
If Not dr(i) is DbNull.Value Then Debug.WriteLine(dr(i))
Next
End While
End If
'close up
dr.Close
SqlConnection1.Close