[thelist] Using @@Identity

Casey aspnet at thecrookstons.com
Tue Aug 23 18:52:11 CDT 2005


Ok.  Wrong  subject.  Once again...


I was able to get this far (see below) from:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_globals_50u1.asp

Now I just need to know how to retreive the value of Identity. All this is
being done in ASP.NET using VB and an MS SQL Database.  The colum in
question is doc_id which is set as the auto-incrementing Primary Key.

Any pointers?

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, ...) SELECT @@IDENTITY AS
'Identity'"

Dim cmdInsert As SqlCommand = NEW SqlCommand(strInsert, conAddDoc)

conAddDoc.Open
cmdInsert.ExecuteNonQuery()
conAddDoc.Close





More information about the thelist mailing list