好的,这是我的问题。我正在为工作制作一个新的 GUI。没什么特别的,只是输入要打印在标签上的信息。我已经设法让代码在单击按钮时将值插入到 MainLabel 表中,但我还需要这些来更新 Label 表中的第一行。
由于某种原因,它会插入但不进行更新。我怎样才能做到这一点?这是我有任何帮助将不胜感激。
更新了还是不行
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Jim\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\labels1.mdb;Persist Security Info=False";
OleDbCommand cmd = new OleDbCommand();
OleDbCommand cmd1 = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd1.CommandType = CommandType.Text;
cmd1.CommandText = "UPDATE Label SET SaleOrderNumber = @SaleOrderNumber, NsN = @NsN, NsNBarcode = @NsNBarcode, PartNumber = @PartNumber, Qty = @Qty, Description = @Description, CustomerPo = @CustomerPo, CustomerPoBarcode = @CustomerPoBarcode, PackingCode = @PackingCode, Weight = @Weight, Clin = @Clin, SaleOrderDate = @SaleOrderDate, MCM = @MCM, Cage = @Cage ";
cmd.CommandText = "INSERT into MainLabel ([SaleOrderNumber], [NsN], [NsNBarcode], [PartNumber], [Qty], [Description], [CustomerPo], [CustomerPoBarcode], [PackingCode], [Weight], [Clin], [SaleOrderDate], [MCM], [Cage]) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,? ,?)";
cmd.Parameters.AddWithValue("@SaleOrderNumber", label1.Text);
cmd.Parameters.AddWithValue("@NsN", label6.Text);
cmd.Parameters.AddWithValue("@NsNBarcode", label6.Text);
cmd.Parameters.AddWithValue("@PartNumber", label2.Text);
cmd.Parameters.AddWithValue("@Qty", label7.Text);
cmd.Parameters.AddWithValue("@Description", label3.Text);
cmd.Parameters.AddWithValue("@CustomerPo", label8.Text);
cmd.Parameters.AddWithValue("@CustomerPoBarcode", label8.Text);
cmd.Parameters.AddWithValue("@PackingCode", label4.Text);
cmd.Parameters.AddWithValue("@Weight", label9.Text);
cmd.Parameters.AddWithValue("@Clin", label5.Text);
cmd.Parameters.AddWithValue("@SaleOrderDate",label12.Text);
cmd.Parameters.AddWithValue("@MCM", label10.Text);
cmd.Parameters.AddWithValue("@Cage", label11.Text);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
con.Close();