Reputation: 89
I have an Object Query in MS Access named "getLicense" that will execute the following:
SELECT * FROM tblLicense;
In my C# WinForm Application, I'm trying to execute the "getLicense" Object Query in MS Access through these codes:
/***This does not work***/
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.CommandText = "getLicense";
myReader = myCommand.ExecuteReader();
myReader.Read();
/************************/
/****This is working*****/
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = "SELECT * FROM tblLicense";
myReader = myCommand.ExecuteReader();
myReader.Read();
/************************/
I want to manage my Queries in MS Access DB through Object Queries and not in the hard coded query in C# that's why I'm trying to use the CommandType.StoredProcedure.
Here is the exception
ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Upvotes: 0
Views: 2893
Reputation: 89
It is like an execution of the MSSQL Server Stored Procedure, I have replaced the:
myCommand.CommandText = "getLicense";
with this:
myCommand.CommandText = "EXEC getLicense";
Upvotes: 2