increment ID from 0004 to 0005 instead of 0004 to 5.

thejeraldo

Well-known member
Joined
Jun 9, 2009
Messages
70
Location
Philippines
Programming Experience
1-3
anybody can help me with this?

i need to get the max ID number and then increment it. ive already done that. but the problem is if the max ID number from the table is 0004 the number i get with my code is only 5, what i need is 0005. my data type is int32.

thanks in advance! :)

VB.NET:
daGenID = New OleDb.OleDbDataAdapter("SELECT MAX(empid) from employees", con)
        daGenID.Fill(ds, "genid")
        intLastID = ds.Tables("genid").Rows(0).Item(0) + 1
 
You cannot store 0005 in an int32, simply the number 5 or 4 or 3 etc.

So if you are seeing 0004 that must be a display format. So where are you seeing 0004?
 
go to DataGridView Tasks (little arrow in upper right corner)
Edit Columns
Select the column and go to the DefaultCellStyle property
In Format put 0000
 

Latest posts

Back
Top