hey guys,
I am creating a Materials resource planning system for an admin to be able to keep track of the materials needed, used etc.
When I receive an order via the phone the admin will enter in the size of the product they want and the amount of boxes needed (20 items per box).
This will then calculate all the materials needed to make the order (eg: small Jars, Large Jars, lids and stickers).
I am looking to find a solution to when the order is put through the system to deduct these materials needed to complete this order, to make sure the stock levels are kept up to date and do not run out of materials.
Therefore i am looking for a way to take the figure that shows up in a label on a web form away from the database level which is stored in a table called StockTable.
I have this code only for one material (stickers) to see if it worked, which it didnt.
this is my code:
- protected void Button1_Click(object sender, EventArgs e)
- {
-
- string cs = System.Configuration.ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString;
- SqlConnection con = new SqlConnection(cs);
-
- SqlCommand cmd = new SqlCommand("UPDATE StockTable SET AmtOfStickers-'" + txtStickers.Text, con);
- con.Open();
- cmd.ExecuteNonQuery();
- con.Close();
- Response.Redirect("stock.aspx");
- }
- }
this is the error i am getting:
An exception of type 'System.InvalidOperationException' occurred in System.Data.dll but was not handled in user code
Additional information: ExecuteNonQuery: Connection property has not been initialized.
any advice is greatly appriciated.