Member Avatar for Rahul47

Hello Guys,
I have a table having a column called Sr.No.
And I Wish that everytime i make an entry into that table Sr.No should be auto Incremented.

How Can I Achieve this Functionality ?

Thanks

Member Avatar for Rahul47

@pritaeas: Thanks for your cocern but my problem is solved..

I am using SQL Server which is embedded in VB.NET.

Modifying the property of Identity Column you can achieve this functionality.

@Rahul just Executescalar.

For example

insert_coupon_query As String = ("INSERT INTO qa_discountcoupons (status_code) VALUES (5); SELECT LAST_INSERT_ID()")
                Dim cmd_query As New SqlCommand(insert_coupon_query, objConn)
                Dim cmd_result As Integer = CInt(cmd_query.ExecuteScalar())

                textbox1.text = val(cmd_result) + 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.