Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
saidev
Posting Yak Master
101 Posts |
Posted - 2006-09-13 : 00:53:56
|
Hi Guys,I have 10 fields on a form. I can add the data to 9 fields but the 10th field should be auto generated number. I have 1 auto generated column in backend sql server2000. If i want to get the auto generated column for my 10th field on the form, how to get that.can you guys help me with code. i am using VB.NET/ASP.NET. Appreciate your help.Thanks, |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-09-13 : 01:08:38
|
You won't get the number until you run the INSERT statement. You can get the last allocated Identity column value in SQL by using the SCOPE_IDENTITY() function.A good way to do it is to create a stored proc to insert your new record, and have it return the newly created number as a return parameter. Check out the ADO.NET documentation on how you return parameters from stored procedures.You can create a framework for allocating your own auto-numbers using a next-number table, but this is not a trivial change. |
 |
|
|
|
|