Hello,
I have a Microsoft Access DB connected to a Windows Form Application.
This DB is going to be used as a tracking system. I tried to code the search button to check the Access file based on a certain criteria that is typed in by the user. There are several fields:
Last Name, First Name, etc. Below is the code I have to try to have search the Access DB file. Am I missing another piece that should return the data searched? I tried checking
http://msdn.microsoft.com and I have a book for windows form applications but couldn't find an answer. Any help in the right direction would be appreciated.
Public Sub ReadMyData(ByVal myConnString As String)
Dim mySelectQuery As String = "SELECT Medical Record Number, Last Name, First Name FROM Table1 where lastname ='" + TextBox1.Text + "'"
Dim myConnection As New OleDbConnection(myConnString)
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As OleDbDataReader
myReader = myCommand.ExecuteReader()
While myReader.Read()
Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _
+ myReader.GetString(1))
End While
Thank you.