December 10th, 2003, 03:32 PM
:: 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.
December 11th, 2003, 11:47 PM
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.Rows
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
January 20th, 2004, 10:23 PM
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.