I am far from expert at this stuff. Do you know how to return your data to a different for then the one you used to search? My "Hasrows" is not working either. Does anyone know why? Here is my coding so far:
VB Code:
  1. Dim SqlConn As New SqlConnection("data source=localhost;initial catalog=crdatabase;integrated security=SSPI;persist security info=False;workstation id=CRSERVER;packet size=4096")
  2.         Dim cmdSqlCommand1 As SqlCommand = New SqlCommand("SELECT * FROM tblHUDdata", SqlConn)
  3.  
  4.         'Opens the DataReader to read data from the tblHUDdata table
  5.         SqlConn.Open()
  6.         Dim drSqlDataReader1 As SqlDataReader = cmdSqlCommand1.ExecuteReader()
  7.         drSqlDataReader1.Read()
  8.         Dim search As String
  9.  
  10.         If IsNumeric(txtSearchCase.Text.Substring(0)) Then
  11.             search = "SELECT * FROM CapRec WHERE CaseNumber LIKE '" & txtSearchCase.Text & "%';"
  12.  
  13.             'txtCaseNum.Text = drSqlDataReader1.Item(0)
  14.  
  15.         Else
  16.             search = "SELECT * FROM CapRec WHERE LastName LIKE '" & txtSearchCase.Text & "%';"
  17.         End If
  18.  
  19.         Dim dr As SqlDataReader
  20.         Dim index As Integer
  21.         cmdSqlCommand1.Connection = SqlConn
  22.         cmdSqlCommand1.CommandText = search
  23.         cmdSqlCommand1.CommandType = CommandType.Text
  24.  
  25.         If drSqlDataReader1.HasRows Then
  26.             While drSqlDataReader1.Read
  27.                 For index = 0 To drSqlDataReader1.FieldCount - 1
  28.                     If Not drSqlDataReader1(index) Is DBNull.Value Then Debug.WriteLine(drSqlDataReader1(index))
  29.                 Next
  30.             End While
  31.         End If
  32.         'close up
  33.         drSqlDataReader1.Close()
  34.         SqlConn.Close()