Thanks
Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchButton.Click
Dim ind As String = 0
' Dim Result As String
Dim SearchArgument As String
SearchArgument = Me.SearchTextBox.Text
Dim cmd As OleDbCommand 'Object stores the SQL command text and connection info
'the SQL Command
'Instantiate a new OleDbCommand object using the CommandString value
'and the ConnectionString value of the PersonalTableAdapter object.
With EmployeeTableAdapter
If .Connection.State = ConnectionState.Closed Then
.Connection.Open()
Debug.WriteLine("Conn: WAS CLOSED, NOW OPEN")
End If
If LastNameRadioButton.Checked = True Then
Dim cmdString As String = "SELECT * FROM Employee WHERE Last Name = SearchArgument"
cmd = New OleDbCommand(cmdString, .Connection) 'I am going off of your lab 10. Sorry I am having so
TheReader = cmd.ExecuteReader() 'Now retrieve the resulting rows
End If
If IDRadioButton.Checked = True Then
Dim cmdString As String = "SELECT * FROM Employee WHERE ID = '3'" ' if you can figure out how to pass a variable here
cmd = New OleDbCommand(cmdString, .Connection)
TheReader = cmd.ExecuteReader() 'Now retrieve the resulting rows
End If
'cmd = New OleDbCommand(cmdString, .Connection) 'I am going off of your lab 10. Sorry I am having so much trouble...
If TheReader.HasRows() Then
Do While TheReader.Read()
With Me.SearchResultsListBox.Items
.Add(String.Format("{0,-3} {1,-10} {2,-15} {3,10} {4,20}, {5,-2} {6,-15} {7,-10}", TheReader("ID"), TheReader("First Name"), _
TheReader("Last Name"), TheReader("Phone Number"), _
TheReader("Comments"), TheReader("Status"), TheReader("Picture"), _
TheReader("File Name")))
End With
Loop
Debug.WriteLine("AFTER ExecuteReader()")
Else
MessageBox.Show("No Rows returned by QUERY! ")
End If
End With
End Sub
End Class

New Topic/Question
Reply




MultiQuote





|