I'm currently connecting to and working with a MS Access database. I can do a generic select * query fine, so I am connected to the db, but when I try to select using parameters it throws a missing operator exception.
string selectStatement = "Select ID from pages where page_title = ? limit 1";
string title = Request.QueryString["pagetitle"];
OleDbCommand selectCommand = new OleDbCommand(selectStatement, conn);
selectCommand.Parameters.Add("@p1",OleDbType.VarChar);
selectCommand.Parameters["@p1"].Value = System.Web.HttpUtility.UrlDecode(title);
OleDbDataReader selectResult = selectCommand.ExecuteReader();
The error I get is on the ExecuteReader line:
Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'page_title = ? limit 1'.
I've tried using @p1 inside the query, as well as the current ?. I've tried adding the parameters different ways, including removing the @ in the parameter name. Nothing seems to work. Can someone point me in the right direction?