Hi All,
I am using ODBC connection to connect my SQlite database. its is working fine for insert and delete data but if i am updating any data then i am getting below error.
"ERROR [HY000] parameter marker count incorrect (1)"
here is my query which i am using :
SQLConnection.Instance.Open();
OdbcCommand mySQLiteCommand = SQLConnection.Instance._dbCon.CreateCommand();
mySQLiteCommand.CommandText = "Update SyncTable set LastTime = @LastTime,Status = @Status Where DisplayName = '" + task.Key + "'and UserName = '" + loginObj.Key + "'";
mySQLiteCommand.Parameters.Clear();
mySQLiteCommand.Parameters.Add(new OdbcParameter("@LastTime", task.Value as object));
mySQLiteCommand.Parameters.Add(new OdbcParameter("@Status", status as object));
mySQLiteCommand.ExecuteNonQuery();
SQLConnection.Instance.Close();
i am not getting where i am doing wrong.Please help me.
Thanks
VulpesPosted Oct 21, 2013, 5:16 AM
mySQLiteCommand.CommandText = "Update SyncTable set LastTime = ?, Status = ? Where DisplayName = '" + task.Key + "'and UserName = '" + loginObj.Key + "'";
RobbinsonPosted Oct 21, 2013, 6:37 AM
it was not working because OLE DB.NET Framework Data Provider uses positional parameters that are marked with a question mark (?) instead of named parameters.
you can get more description about how parameters are working for oledb provider over here.
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbparameter.aspx
Hope, this would help you to understand why it was not working.
Don't forget to mark as answer if this post helps you.
Sumit KumawatPosted Oct 21, 2013, 6:27 AM
Sumit KumawatPosted Oct 21, 2013, 6:26 AM
RobbinsonPosted Oct 21, 2013, 5:02 AM
This error is similar to parameter index out of range. Please try with removing '@' from OdbcParameter class parameters. Below is updated statement to get an idea.
mySQLiteCommand.Parameters.Add(new OdbcParameter("LastTime", task.Value as object));
mySQLiteCommand.Parameters.Add(new OdbcParameter("Status", status as object));
Hope, this will help you out.
Please Don't forget to mark as answer if this post helps you.