automatic id generation which is a primary key

Posted by abhi on Stack Overflow See other posts from Stack Overflow or by abhi
Published on 2010-05-20T09:52:50Z Indexed on 2010/05/20 10:00 UTC
Read the original article Hit count: 335

Filed under:
|
|

in vb.net while entering a new entry i want to assign a record a unique id like in case of numeric i do this way

Dim ItemID As Integer
KAYAReqConn.Open()
SQLCmd = New SqlCommand("SELECT ISNULL(MAX(ItemID),0) AS ItemID from MstItem", ReqConn)
Dim dr As SqlDataReader

dr = SQLCmd.ExecuteReader
If dr.HasRows Then
    dr.Read()
    ItemID = dr("ItemID") + 1
End If
dr.Close()

in this case m using itemid as a unique id and the format is 1,2,3... and m finding out the max and assigning to a new record but how to assign if the previous id is of the a00001,a00002,a00003,a00004...so on. how i do i produce a unique id in this case

© Stack Overflow or respective owner

Related posts about sql

Related posts about ASP.NET