Error in executing an OleDbCommand.. “Must declare the scalar variable ”@MaxID“.”

后端 未结 4 1179
醉梦人生
醉梦人生 2021-01-14 07:48
private void AddValue(string strValue)

{

      //get the maximum id for Lists first

      int MaxID = DataOperations.ReturnMaxIDInATable(\"Lists\", connString);
          


        
4条回答
  •  攒了一身酷
    2021-01-14 07:58

    I believe you need to use question marks for the parameters when executing SQL through the OleDbCommand (while SqlCommand uses @). Example:

    INSERT INTO Lists (ID, ListName, ListValue) VALUES (?, ?, ?)
    

    You only need to Add the Parameters in the order that they appear in the SQL.

提交回复
热议问题