straight_edge
Member
- Joined
- Feb 21, 2007
- Messages
- 13
- Programming Experience
- Beginner
Hi
I have a VB.Net project linked to an access database, so far I can display the information from the database tables in text files, and add and delete data from the database.
Now I wish to a have a query set up so the user can search for a specific record in the databse by a field but I keep getting an error message.
The code I am using is:
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = N:\Database.mdb"
con.Open()
Dim userEnteredID As String
Dim command As String
Dim dataset As New DataSet
Dim dataAdapter As OleDb.OleDbDataAdapter
userEnteredID = InputBox("Please enter an ID")
command = "SELECT * FROM table WHERE " & "ID = " & " '" & userEnteredID & "'"
dataAdapter = New OleDb.OleDbDataAdapter(command, con)
dataAdapter.Fill(dataset , "Database")
con.Close()
The error message highlights:
dataAdapter.Fill(dataset, "Database")
and says "Data type mismatch in criteria expression"
If anyone can help it would be very much appreciated
Thanks
I have a VB.Net project linked to an access database, so far I can display the information from the database tables in text files, and add and delete data from the database.
Now I wish to a have a query set up so the user can search for a specific record in the databse by a field but I keep getting an error message.
The code I am using is:
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = N:\Database.mdb"
con.Open()
Dim userEnteredID As String
Dim command As String
Dim dataset As New DataSet
Dim dataAdapter As OleDb.OleDbDataAdapter
userEnteredID = InputBox("Please enter an ID")
command = "SELECT * FROM table WHERE " & "ID = " & " '" & userEnteredID & "'"
dataAdapter = New OleDb.OleDbDataAdapter(command, con)
dataAdapter.Fill(dataset , "Database")
con.Close()
The error message highlights:
dataAdapter.Fill(dataset, "Database")
and says "Data type mismatch in criteria expression"
If anyone can help it would be very much appreciated
Thanks