Hey guys I need a little assistance in doing a basic search query from my form program to connect to an access database. basically I want to learn how to with the click of my query button, search text entered in a textbox and show the corresponding data in another text box, based on a match found. Any help would be greatly appreciated.
here is the code of my query button so far..
Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click
con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Eric\Documents\Fadv.accdb")
con.Open()
Dim id As Integer
Dim SQL As String = "SELECT FirstName, NAME FROM info WHERE FirstName=" & txtFirstName.Text & ""
Using cmd As New OleDbCommand(SQL, con)
id = Val(InputBox("Enter Query Criteria"))
MsgBox(SQL)
cmd.ExecuteNonQuery()
con.Close()
End Using
Im having a little trouble trying to figure out the (connectionstring) Im not sure if this is something I have to declare so far here is that my code, any guidance would be greatly appreciated.
` Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click
Using con As New OleDbCommand(connectionstring)
Dim cmd As New OleDbCommand(SQL, con)
con.open()
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
txtFirstName.Text = reader(0).ToString())
End While
reader.Close()
End Using
`