c# - add db column to textbox and save it in db (total) -


i want add value in textbox column in db called quantity using update, every time click save collection in db (quantity) i'm sorry english not good

note: db=invoice , table=product edit: solve , hope code usefull ppl

         private void button1_click(object sender, eventargs e)     {         sqlconnection con = new sqlconnection("data source=nawaf;initial catalog=invoice;integrated security=true");          con.open();         sqlcommand cmd = new sqlcommand(@"insert [invoice].[dbo].[invoice]             ([invoice_number]             ,[inventory_id]             ,[received_date]             ,[supplier_code]             ,[supplier_name]             ,[product_code]             ,[product_name]             ,[serial_number]             ,[mgf_date]             ,[product_unit]             ,[receivedq])        values                  ('" + textbox1.text + "' ,'" + combobox1.text + "' , '" + textbox3.text + "' , '" + combobox2.text + "' , '" + combobox3.text + "' , '" + combobox4.text + "' , '" + combobox5.text + "' , '" + textbox2.text + "' , '" + textbox4.text + "' , '" + combobox6.text + "' , '" + textbox6.text + "')", con);                 cmd.executenonquery();                 con.close();                con.open();                sqldataadapter sda = new sqldataadapter("select invoice_number,received_date,supplier_code,supplier_name,product_code,product_name,serial_number,mgf_date,receivedq invoice   invoice_number '" + textbox1.text + "'", con);                datatable dt = new datatable();                sda.fill(dt);                datagridview1.datasource = dt;               sqlcommand ccm= new sqlcommand("update product set quantity += '" + textbox6.text + "' product product_name '" + combobox5.text + "'", con);                ccm.executenonquery();                textbox3.text = "";                textbox2.text = "";                textbox4.text = "";                combobox4.text = "";                combobox5.text = "";                combobox6.text = "";                textbox6.text = "";                con.close();        } 

actually not understand in query have problem insert or update ? can try insert this:

string query="insert [invoice].[dbo].[invoice]([invoice_number],[inventory_id],[received_date],[supplier_code],[supplier_name],[product_code],[product_name],[serial_number],[mgf_date],[product_unit],[receivedq])           values('" + textbox1.text + "' , '" + combobox1.text + "' , '" + textbox3.text + "' , '" + combobox2.text + "' , '" + combobox3.text + "' , '" + combobox4.text + "' , '" + combobox5.text + "' , '" + textbox2.text + "' , '" + textbox4.text + "' , '" + combobox6.text + "' , '" + textbox6.text + "')"  =new sqlcommand(query, con);  , update query this:  new sqlcommand("update p set quantity = '" + textbox6.text + "' product p product_name '" + combobox5.text + "'") 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -