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

后端 未结 4 1218
醉梦人生
醉梦人生 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 08:21

    This seemed to do the trick..

    string query = string.Format("INSERT INTO Lists(ID, ListName, ListValue) 
             VALUES({0}, '{1}', '{2}')", MaxID, ListName, strValue);
    

    Although I have reservations about it like what if I need to add a date value?

提交回复
热议问题