Hello,
I just wanna do a simple operation. My sql query is below;
UPDATE IP_KONTROL SET up_down= '" + rdr["up_down"] + 1 + "' WHERE spe = '" + specif + "' ", conn
I just want to increase rdr's value 1, and Update it. I mean I want to increase rdr["up_down"]'s value. But it isnt adding +1. For example if rdr["up_dow"]'s value is 2, and then it is updating "21".. It should be "3", not "21". How can i do that?
Loading
Suthish NairPosted Dec 19, 2010, 5:09 AM
For more, refer article.
Subhendu DePosted Dec 18, 2010, 11:24 PM
int i = 2;
int j = 1;
(i+j) would give you (2+1) = 3. The mathematical sum happens here.
string i = "2";
string j = "1";
(i+j) would give you ("2" + "1") = "21". The concatenation happens here.
So do in this way
UPDATE IP_KONTROL SET up_down= '" + Convert.ToString( (Convert.ToInt32(rdr["up_down"]) + 1)) + "' WHERE spe = '" + specif + "' ", conn
Convert the string to int and then do the sum. Again convert it to string.
Thanks.....