Increment Variable by 1

rogerino88

New member
Joined
Feb 20, 2025
Messages
2
Programming Experience
5-10
Hi all, the increment of an integer variable does not work well once I retrieve it from the database. Basically the increment works up to 10..When you have to go from 10 to 11 it no longer works.This is the code

C#:
 OleDbCommand cmdDDT = new OleDbCommand("SELECT TOP 1 n_ddt FROM bolla_cl ORDER BY n_ddt DESC ", connection);
 Int32 ddt = Convert.ToInt32(cmdDDT.ExecuteScalar());
 ddt = ddt + 1;
 MessageBox.Show(Convert.ToString(ddt));
 n_ddt.Text = Convert.ToString(ddt);

Why?

Best Regards
 
If you set a breakpoint on line 2, do you get a value of 10? If so then adding 1 to 10 should give you 11 on line 3 with the corresponding output on the following lines.

How are you writing values back into the database? Perhaps the issue is there rather than in the increment code you presented.
 
Back
Top Bottom