- Aug 31, 2004
- 473
- 0
- 71
I'm using ADO .NET to connect to a Microsoft Access database, and everything so far has been working in my program except one small problem. I am constructing a query string to search for certain results from a table, and it does not seem to return the correct results.
(Visual Basic .NET)
Dim dtResults As New DataTable("SearchResults")
Dim cmdSearchResults As New OleDb.OleDbCommand(queryString, appointments.myConnection)
Dim daSearchResults As New OleDb.OleDbDataAdapter(cmdSearchResults)
daSearchResults.Fill(dtResults)
Debug.WriteLine(dtResults.Rows.Count)
Debug.WriteLine(queryString)
where queryString is the string I have constructed. It looks like this:
SELECT Appointments.AppointmentID, Appointments.AppointmentTime, Buildings.Building, Appointments.RoomNumber, Appointments.Details FROM (Appointments INNER JOIN Buildings ON Appointments.BuildingID=Buildings.BuildingID) INNER JOIN Technicians ON Appointments.TechnicianID=Technicians.TechnicianID WHERE 1 = 1 AND Technicians.TechnicianName = "Matt" AND Appointments.Details LIKE "*test*";
When I copy this directly into a query in MS Access it returns the correct records, however the data adapter in my code returns 0 results. Any ideas as to what the problem is anyone?
-Matt
(Visual Basic .NET)
Dim dtResults As New DataTable("SearchResults")
Dim cmdSearchResults As New OleDb.OleDbCommand(queryString, appointments.myConnection)
Dim daSearchResults As New OleDb.OleDbDataAdapter(cmdSearchResults)
daSearchResults.Fill(dtResults)
Debug.WriteLine(dtResults.Rows.Count)
Debug.WriteLine(queryString)
where queryString is the string I have constructed. It looks like this:
SELECT Appointments.AppointmentID, Appointments.AppointmentTime, Buildings.Building, Appointments.RoomNumber, Appointments.Details FROM (Appointments INNER JOIN Buildings ON Appointments.BuildingID=Buildings.BuildingID) INNER JOIN Technicians ON Appointments.TechnicianID=Technicians.TechnicianID WHERE 1 = 1 AND Technicians.TechnicianName = "Matt" AND Appointments.Details LIKE "*test*";
When I copy this directly into a query in MS Access it returns the correct records, however the data adapter in my code returns 0 results. Any ideas as to what the problem is anyone?
-Matt