Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2006, 01:20 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to auto increment?

Hi, I'm trying to auto-increment reference numbers in my text box. Everytime a user enters my web form the reference number automatically increments, for example, 20060001 and so on.
I'm new to visual studio 2005 and I'm unsure how to go about doing it. Please help.

Shawn
 
Old June 6th, 2006, 01:07 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

when do you want it to increment, after you save some data?

 
Old June 6th, 2006, 07:32 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do I have to use session state?
 
Old June 6th, 2006, 07:35 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes once the user submits the form I want the reference number to auto increment.

 
Old June 7th, 2006, 09:05 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What database are you using. Most DBs have some type of autoincrement column. I would use that, and not rely on the front end to increment it.

 
Old June 10th, 2006, 07:00 PM
Authorized User
 
Join Date: Apr 2006
Location: Stockholm, , Sweden.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Shawn Mohan
 Yes once the user submits the form I want the reference number to auto increment.

My guess is you're using the included SQL Server Express db. If so, doubleclick the table you want to have an incrementally updated column for, then click the field in question (your_ID). In the Column properties, set Identity Specification to Yes and open its properties by clicking the + sign in front of the Idendity Spec. text.

Next, choose your values in increment (how big jumps you want) and also seed (the first value). That's it!

Good luck,
Pettrer

Coding is indeed a nine-to-five job; nine pm to five am.
 
Old June 20th, 2006, 10:36 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for not stating this but my datatype for my reference number is char(9). It should begin like this, 2006-0001,2006-0002 etc





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding auto increment of id Rajesh225 ASP.NET 1.0 and 1.1 Basics 1 June 27th, 2007 05:35 PM
Auto increment prad_a MySQL 3 April 7th, 2007 05:47 AM
How to auto increment ? Shawn Mohan SQL Server 2000 2 June 22nd, 2006 03:00 AM
Auto-increment using VBScript CraigKornacki VB How-To 1 April 6th, 2004 02:17 PM
auto increment? hosefo81 PHP Databases 1 February 2nd, 2004 03:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.