|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
:: problem in UPDATE statement ::
I want to do something like below(in ASP.NET & C#):
string strupdate = "UPDATE table SET field = field + intvariable WHERE otherfield = yes"; but i don't know how i can do (add a variable value to a numerical field in a ACCESS database). Please give me the right string. |
|
#2
|
|||
|
|||
|
u first get the value of the field by using SELECT
then u add ur value to it then u write with UPDATE so u do something like this SELECT field FROM table WHERE .... then u get a dataset back, u put that value in a variable in ur code int myVar = myDataSet.Tables[0].Rows[0] then you add ur new data to that variable thenn u write back using UPDATE TABLE Set Field = " + myVar.ToString(); .... thats one way of doing it Kovan, |
|
#3
|
||||
|
||||
|
You have two methods, constructing a SQL seatment at run time by concatinating strings together or, the faster method, is to create a query in Access. Then use the Command and Parameter objects to run it. I much prefere the second option.
If you are still having problems then post some code and I'll take a gander at it. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > :: problem in UPDATE statement :: |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|