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:
Dim SqlConn As New SqlConnection("data source=localhost;initial catalog=crdatabase;integrated security=SSPI;persist security info=False;workstation id=CRSERVER;packet size=4096") Dim cmdSqlCommand1 As SqlCommand = New SqlCommand("SELECT * FROM tblHUDdata", SqlConn) 'Opens the DataReader to read data from the tblHUDdata table SqlConn.Open() Dim drSqlDataReader1 As SqlDataReader = cmdSqlCommand1.ExecuteReader() drSqlDataReader1.Read() Dim search As String If IsNumeric(txtSearchCase.Text.Substring(0)) 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 dr As SqlDataReader Dim index As Integer cmdSqlCommand1.Connection = SqlConn cmdSqlCommand1.CommandText = search cmdSqlCommand1.CommandType = CommandType.Text If drSqlDataReader1.HasRows Then While drSqlDataReader1.Read For index = 0 To drSqlDataReader1.FieldCount - 1 If Not drSqlDataReader1(index) Is DBNull.Value Then Debug.WriteLine(drSqlDataReader1(index)) Next End While End If 'close up drSqlDataReader1.Close() SqlConn.Close()




Reply With Quote