I am trying to join 3 tables in my MS Access database in C#. Whenever I run the code, i get an error saying "Missing Operator in query expression". I have also just copied the SQL statement directly into MS Access and ran it, and it returned the same error, since I was thinking it may have been a formatting issue in VS.
The actual SQL statement that causes the error:
SELECT Products.ProductName, Keys.Key, Keys.Active, Transactions.Total, Transactions.TransactionDate
FROM Keys
INNER JOIN Transactions
ON Keys.TransactionID = Transactions.TransactionID
INNER JOIN Products
ON Transactions.ProductID = Products.ProductID
WHERE Transactions.UserID = 20
The SQL statement inside of Visual Studio:
command.CommandText =
"SELECT Products.ProductName, Keys.Key, Keys.Active, Transactions.Total, Transactions.Date " +
"FROM Keys " +
"INNER JOIN Transactions ON Keys.TransactionID = Transactions.TransactionID " +
"INNER JOIN Products ON Transactions.ProductID = Products.ProductID " +
"WHERE Transactions.UserID = " + UserID;
OleDbDataReader reader = command.ExecuteReader();