Ok, here is my problem. I am making a new GUI for work. Nothing fancy, just something to enter information to be printed out on labels. I have managed to get the code working to insert the values into the MainLabel table on button click, but I also need these to UPDATE just the first row in the Label table.
For some reason it will insert but not do the update. how can I make that happen? Here is what I have Any help would be greatly appreciated.
Updated still not working
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();