query statement returns error only in code

  • Thread starter Thread starter CSharp
  • Start date Start date
C

CSharp

Hello all,

I have to execute the following simple query in MS Access and I am using the
OleDbCommand object to do this.

SELECT Entries.MessageID, Entries.DatePosted, Entries.MessageBody,
User.UserName FROM Entries INNER JOIN User ON Entries.UserID=User.UserID

I get an error saying:
Syntax error in FROM clause

I saved the SQL statement as a query in MS Access and I am able to run the
query from Access and get results. Why is that I get an error when trying to
execute the query from my C# code?

Thanks
CSharp
 
It helped :)

Thanks,
CSharp

Miha Markic said:
Hi,

Try putting square brackets around user: [User].

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

CSharp said:
Hello all,

I have to execute the following simple query in MS Access and I am using the
OleDbCommand object to do this.

SELECT Entries.MessageID, Entries.DatePosted, Entries.MessageBody,
User.UserName FROM Entries INNER JOIN User ON Entries.UserID=User.UserID

I get an error saying:
Syntax error in FROM clause

I saved the SQL statement as a query in MS Access and I am able to run the
query from Access and get results. Why is that I get an error when
trying
to
execute the query from my C# code?

Thanks
CSharp
 
Back
Top