The following code in vb.net 2010 express generates this error:
syntax error (missing operator) in query expression ''.
sql = "SELECT Machines.LocationID FROM Lanes LEFT JOIN Cabinets ON
Lanes.CabinetID=Cabinets.ID AND Cabinets.Name IS NOT NULL LEFT JOIN Machines ON
Cabinets.MachineID=Machines.ID "
Dim mAdapter As New OleDbDataAdapter(sql, con)
Dim mt As New DataTable("Results")
mAdapter.Fill(mt)
con is defined in a module of the project as:
Public myConString As String = "Provider=Microsoft.ACE.OLEDB.12.0"
Public databaseName As String = "C:\vending.mdb"
Public con As New OleDb.OleDbConnection(myConString & ";Data Source =" & databaseName)
If I comment out the second Left Join command, the statement executes properly. This exact same sql statement when executed from SQL Server works fine.
Tables are defined as:
Locations
ID INTEGER IDENTITY
Company
Name
...
Machines
ID INTEGER IDENTITY
LocationID Integer
Name as Text(100)
SerialNum as Text(100)
...
Cabinets
ID INTEGER IDENTITY
Name TEXT(100)
MachineID INTEGER
...
Lanes
ID INTEGER IDENTITY
Name TEXT(100)
CabinetID INTEGER
...
If I add parentheses around the join statements like so:
sql = "SELECT Machines.LocationID FROM ((Lanes LEFT JOIN Cabinets ON
Lanes.CabinetID=Cabinets.ID AND Cabinets.Name IS NOT NULL) LEFT JOIN Machines ON
Cabinets.MachineID=Machines.ID) "
I get the error:
Join expression not supported.
PLEASE HELP!