Zpixel
08-31-2009, 06:43 PM
I write this sql query to update a column by 1 unit.
strsql="update products set qty=qty+1 where id=" + id + "";
when i look at database, i see an increase by 2.
example:
qty is an integer column in a table.
before query : qty=5
i expect : qty=6 after query but
after query: qty=7
what's wrong?
the query is runned just one time.
------------------ second question
inside one query, i want to run another query. but compiler gives error and says that i should
close the previous datareader first. i can't close the former datareader because the query result is being read through a while loop.
first query
while(result.read()){
....
id=convert.ToInt32(result[0]);
...
second query using id
}
How can i run one query inside another one?
thanks.
strsql="update products set qty=qty+1 where id=" + id + "";
when i look at database, i see an increase by 2.
example:
qty is an integer column in a table.
before query : qty=5
i expect : qty=6 after query but
after query: qty=7
what's wrong?
the query is runned just one time.
------------------ second question
inside one query, i want to run another query. but compiler gives error and says that i should
close the previous datareader first. i can't close the former datareader because the query result is being read through a while loop.
first query
while(result.read()){
....
id=convert.ToInt32(result[0]);
...
second query using id
}
How can i run one query inside another one?
thanks.