使用添加为值的参数执行此查询时,出现错误,提示我的语法错误。我尝试了以下多个教程,在这里查找问题是堆栈溢出,并且进行比较时,它们似乎相同,但是我的似乎不起作用。
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source =C:\\Users\\fidyc\\OneDrive\\Desktop\\ProgrII.accdb";
OleDbCommand cmd = new OleDbCommand("INSERT Product_Orders(order_ID,plankCount,thickness,width,height)VALUES(@order_ID, @plankCount, @thickness, @width, @height)");
cmd.Parameters.Add("@order_ID", OleDbType.Integer).Value = orderID;
cmd.Parameters.Add("@plankCount", OleDbType.Decimal).Value = plankCount;
cmd.Parameters.Add("@thickness", OleDbType.Decimal).Value = thickness;
cmd.Parameters.Add("@width", OleDbType.Decimal).Value = width;
cmd.Parameters.Add("@height", OleDbType.Decimal).Value = height;
cmd.Connection = con;
con.Open();
if (con.State == ConnectionState.Open)
{
/*try
{*/
cmd.ExecuteNonQuery();
MessageBox.Show("Data Added");
con.Close();
/*}
catch (OleDbException ex)
{
MessageBox.Show(ex.Source);
con.Close();
}*/
}
编辑:值传递给函数
public static void Push(int orderID, decimal plankCount, decimal thickness, decimal width, decimal height)
{
慕田峪9158850
慕桂英4014372
相关分类