0

Hi..
I hav a database for maintaining emp details. I want to get my EmpID to be generated automatically when my add new button is clicked. That too in C# only...

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by greeny_1984
0

hi,

u can use ideintity for the column u want to increment empid.
u have to set identity in the column properties as 1.

0

The best method to do this is in your DateBase Table.
Add a primary key ID field of type integer with identity specification set to true. It will increment your ID field on each row insert

0

In VB i used the below coding for generating number automatically. It worked.
But in C# i cant able check whtr the database in null or not. Is thr any option?

If dr.Read() Then
If IsDBNull(dr(0)) Then
txtempid.Text = "101"
Else
txtempid.Text = ds1.Tables(0).Rows(0).Item(0) + 1
'Where ds contains the max value of the empid
End If
End If

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.