Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI...

i want to generate a sequence number in quotation page (i.e. in Quotation ID).... how to generate this number programmatically and store the details including the auto generate in sql database....

Have to show the auto generate number in asp.net page....
Posted
Updated 7-Jul-11 23:29pm
v2

Use an index in the DB and just show the number from that.
 
Share this answer
 
The easiest way is to set up an int field in the database, and change it's "Identity" propetry to "True".
I don't have SQL 2005 at the moment, but it is very similar to teh procedure for SQL 2008. In the SQL Sever management tool:
1) Create your table and edit it, either by select "New Table" from the context menu when you right click "Tables" under your database name, or via the "Design" from the context menu when you right click the table name.
2) Select the empty row at the bottom, and give the field a sensible number: "quoteId" is good.
3) Under DateType, select "int"
4) Deselect "Allow nulls"
5) In the "Column Properties" pane, find "Identity Specification". Expand it, via the "+" sign to it's left.
6) Change "Is identity" to "Yes"
7) Done - the database will now keep that field updated for you, and will increment it by one each time you insret a new row.
 
Share this answer
 
Comments
nithibs 8-Jul-11 5:28am    
Actually this can be done very easily by using IDENTITY keyword while creating table.... i am asking that i have to display the autogenerate number in asp.net page....
OriginalGriff 8-Jul-11 5:34am    
...which is exactly the same thing, if you are setting up the table using a query.
nithibs 8-Jul-11 6:04am    
k.... how to bind the number from database to asp.net page (particular textbox)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900