We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,459 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Auto Increment a Sr_No in table.

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

3
Contributors
3
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
4
Views
Question
Answered
Rahul47
Junior Poster in Training
84 posts since Jan 2013
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

What database are you using?

pritaeas
Posting Prodigy
Moderator
9,533 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

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

Rahul47
Junior Poster in Training
84 posts since Jan 2013
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 4 Months Ago by pritaeas

@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
ryan311
Posting Whiz in Training
294 posts since Jul 2008
Reputation Points: 3
Solved Threads: 6
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0604 seconds using 2.66MB