I'm trying to make an SQL query with an OleDbCommand into an Access database (.accdb).
While this command works fine (in a OleDbCommand.ExecuteReader()
):
string command =
"SELECT cred.* " +
"FROM TB_CREDENTIALS cred " +
"INNER JOIN TB_REL_USERS_CREDENTIALS rel ON cred.CRED_ID = rel.REL_USR_CRED_CRED_ID ";
This other doesn't, and I can't understand why (all examples I see around use the exact same syntax):
string command =
"SELECT cred.* " +
"FROM TB_CREDENTIALS cred " +
"INNER JOIN TB_REL_USERS_CREDENTIALS rel ON cred.CRED_ID = rel.REL_USR_CRED_CRED_ID " +
"INNER JOIN TB_USERS usr ON usr.USR_ID = rel.REL_USR_CRED_USER_ID ";
The exception given is the following System.Data.OleDb.OleDbException
:
Syntax error (missing operator) in query expression 'cred.CRED_ID = rel.REL_USR_CRED_CRED_ID INNER JOIN TB_USERS usr ON usr.USR_ID = rel.REL_USR_CRED_USER_I'
(message is cut here)
Version and details:
- The database is a
.accdb
file created on Access 2010 - The connection is created in C# with
System.Data.OleDb.OleDbConnection
- The connection provider is
"Microsoft.ACE.OLEDB.12.0"
(This seems like a useless query, but of course I'll add a WHERE usr.SOME_FIELD = some_condition
)