嗨,我读过很多关于此的论坛,但是没有解决方案,所以;不断获取命令文本查询中的错误,并且我尝试了所有操作,但无济于事。System.Data.SqlClient.SqlException:“ =”
附近的语法不正确 foreach(ListViewItem item in lvBasket.Items){
SqlCommand cmdNewSuppOrder = new SqlCommand();
SqlConnection con = new SqlConnection(connStr);
cmdNewSuppOrder.CommandText = @" INSERT INTO SupplierOrderDetails (SupplierOrderID = @SupplierOrderID, StockID = @StockID, QTYOrdered = @QTYOrdered) VALUES";
cmdNewSuppOrder.Connection = con;
con.Open();
cmdNewSuppOrder.Parameters.AddWithValue("@SuppOrderID", txtInfoSuppID.Text);
cmdNewSuppOrder.Parameters.AddWithValue("@StockID", item.SubItems[0].Text);
cmdNewSuppOrder.Parameters.AddWithValue("@QTYOrdered", int.Parse(item.SubItems[2].Text));
cmdNewSuppOrder.ExecuteNonQuery();
con.Close();}
注意,我已经在cmdNewSuppOrder.CommandText = @"
之后放置了空格
这里的错误标志也= cmdNewSuppOrder.ExecuteNonQuery();
关于我如何提出问题的任何建议,请随时让我知道。谢谢大家!
INSERT INTO
有两种语法,您的代码中都没有。
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
和
INSERT INTO table_name
VALUES (value1, value2, value3, ...);