SQL query on an MS access DB

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I am trying to run a SQL query on an MS access DB I normally use a data set with a data table to fill my data sets, but this query is too complex for it.
So in stretchered English here goes…
I am passing in the parameters for other sections of code
Parameters are
InZone
InLessionID
InRoomG
InDate
So here is my attempt at the SQL code. I keep getting a syntax error.
SELECT ID, Zone, Subject, Teacher, LessionID, RoomG, Start_Date, End_Date
FROM tblBookings
WHERE Zone = InZone AND LessionID = InLessionID AND RoomG = InRoomG AND Start_Date >= InDate AND End_Date <= InDate
The code I am using is listed below
DimoleConn As New OleDb.OleDbConnection
Dim sql AsString
Dimcommand As New OleDb.OleDbCommand
DimoleAdapter AsNew OleDb.OleDbDataAdapter
Dimusid As String
Dimx As Integer
Handles MyBase.Load
oleConn = New OleDb.OleDbConnection
oleConn.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="|DataDirectory|ICT Booking.mdb"
sql = " SELECT ID, [Zone], Subject, Teacher, LessionID, RoomG, Start_Date, End_Date
FROM tblBookings
WHERE ([Zone] = InZone) AND (LessionID = InLessionID) AND (RoomG = InRoomG) AND (Start_Date >= InDate) AND (End_Date <= InDate)
oleConn.Open()
oleConn.Dispose()
If you could help with the syntax of the SQL query thanks.

View the full article
 
Back
Top