.net - adding value together with the existing value in database -


i developing application , want update information , add value of quantity in existing database new value enter user. it's updating instead of adding quantity it's putting new value @ d of existing value in database e.g if have 5 in database before , 3 in new textbox instead of new value 8, it's showing 35 in database. code, how can adding value con = new oledbconnection("provider=microsoft.jet.oledb.4.0; data source=" & application.startuppath & "\pharmacy.mdb") con.open() dim ct1 string = "select * stock code= '" & txtcode.text & "'"

        cmd = new oledbcommand(ct1)         cmd.connection = con         rdr = cmd.executereader()          if rdr.read              con = new oledbconnection("provider=microsoft.jet.oledb.4.0; data source=" & application.startuppath & "\pharmacy.mdb")             con.open()              dim cb string = "update stock set company = @d1 , productname =@d2, code=@d3, quantity= [quantity] + @d4, unitprice = @d5, ddate = @d6, batchno = @d7, type = @d8, expdate =@d9 " + "where code = @d3"              cmd = new oledbcommand(cb)              cmd.connection = con               cmd.parameters.add(new oledbparameter("@d1", "company"))             cmd.parameters.add(new oledbparameter("@d2", "productname"))               cmd.parameters.add(new oledbparameter("@d3", "code"))              cmd.parameters.add(new oledbparameter("@d4", "quantity"))              cmd.parameters.add(new oledbparameter("@d5", "unitprice"))             cmd.parameters.add(new oledbparameter("@d6", "ddate"))             cmd.parameters.add(new oledbparameter("@d7", "batchno"))             cmd.parameters.add(new oledbparameter("@d8", "type"))             cmd.parameters.add(new oledbparameter("@d9", "expdate"))                cmd.parameters("@d1").value = cmbcompany.text             cmd.parameters("@d2").value = txtprdtname.text              cmd.parameters("@d3").value = txtcode.text               cmd.parameters("@d4").value = txtquantity.text              cmd.parameters("@d5").value = (txtunitprice.text)             cmd.parameters("@d6").value = txtdate.text             cmd.parameters("@d7").value = txtbatchno.text()             cmd.parameters("@d8").value = cmbtype.text             cmd.parameters("@d9").value = dtpexpirationdate.text               cmd.executereader()              messagebox.show("successfully updated", "product details", messageboxbuttons.ok, messageboxicon.information)              rdr.close()             con.close() 


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -