1,105,456 Community Members

Auto Increment a Sr_No in table.

Member Avatar
Rahul47
Posting Whiz
340 posts since Jan 2013
Reputation Points: 13 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 2 [?]
 
0
 

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
pritaeas
mod_pritaeas
11,301 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,833 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

What database are you using?

Member Avatar
Rahul47
Posting Whiz
340 posts since Jan 2013
Reputation Points: 13 [?]
Q&As Helped to Solve: 20 [?]
Skill Endorsements: 2 [?]
 
0
 

@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.

Question Answered as of 1 Year Ago by pritaeas
Member Avatar
ryan311
Posting Whiz in Training
294 posts since Jul 2008
Reputation Points: -7 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

@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
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article