hi friend have sqldatabase in have 3 fields namely **" mc , amount , customername
"** update fileds using upadte command in vb.net form wat need want add
this new value while updating previous value
cmd.commandtext = " update mc set mc = " & textbox3.text & " , amount = " & textbox13.text & " customername = " & " '" & st & "'" & " "
also have problem amount column not being updated
for example let consider
this form data updated mc table
textbox3.text = 600 //sent mc table field name mc
textbox13.text = 10000 //sent mc table filed name amount
customer name = rajesh // mc table customername updated
now mc table have values customername rajesh mc = 500 amount =1250
now problem want update field want sum values of old new 1 , show rajesh should show as
mc = 1100 //since 600+500 amount = 11250 //since 10000+1250 think can understand
plz send me how change code according value
you want then:
cmd.commandtext = " update mc set mc = mc + " & textbox3.text & " , amount = amount + " & textbox13.text & " customername = " & " '" & st & "'" & " "
i suggest using string.format here though. looks lot cleaner.
cmd.commandtext = string.format("update mc set mc = mc + {0}, amount = amount + {1} customername = '{2}'", textbox3.text, textbox13.text, st)
if answer or other answers please mark answer clicking check mark.
Comments
Post a Comment