Click here to Skip to main content
15,908,254 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to retrieve an int type value from database and increment its value by 1,how this can be happened in ASP.NET and C#?
Posted

Connect to the database, then execute a non-query (ExecuteNonQuery) that increments the value in the database (you will use an UPDATE SQL statement).
 
Share this answer
 
It's hard to understand your end requirement but if you just want to get Database value and then increase by 1 in Database then like sugested by AspDotNetDev you can do in a single statement.

Update MyTable SET MyValue = MyValue + 1; Select MyValue - 1 AS ReturnValue FROM MyTable;


Here you can execute this query for Scaler, and in one DB roundtrip you can achieve your goal.

Regards
Rushi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900