[thelist] Key ID of Record Just Created?

Mark Rees mrees at itsagoodprice.com
Tue Aug 23 11:03:52 CDT 2005


----- Original Message -----
From: "Casey" <aspnet at thecrookstons.com>
To: "The List" <thelist at lists.evolt.org>
Sent: Tuesday, August 23, 2005 4:53 PM
Subject: [thelist] Key ID of Record Just Created?


> In ASP.NET / VB.NET, is it possible to discover the key_id of a record
just
> created?  Key ID column is doc_id.
>

If key_id is an SQL Server identity column, then
SELECT @@IDENTITY
after the insert will return this value. It is my understanding that even if
another process inserts another record in between times, this will return
the value you want, ie the key_id of the record just inserted by your script

> TIA!!
>
>
>  Dim conAddDoc As SqlConnection = New
>
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("MccCon
> String"))
>
>  Dim strInsert As String = "Insert MCCIME_Doctor (fname, lname, specialty,
> ....) VALUES (@fname, @lname, @specality, ...)"
>
>  Dim cmdInsert As SqlCommand = NEW SqlCommand(strInsert, conAddDoc)
>
> conAddDoc.Open
>
>   cmdInsert.ExecuteNonQuery()
>
> conAddDoc.Close
>
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>




More information about the thelist mailing list