I have the following SQL command in VB.NET to update a Table on my SQL 2000 server and then i wan to retrieve the key of the newly inserted row. I know this can be done either by @@IDENTITY or be Scope_Identity(). Though i don't know how to reference the specific value returned from the SELECT statement.
Dim cmd As New SqlCommand("insert into NewMail(MessageID,FromAddr,ReplyTo,MailTime,Subject,contentType,Encoding,Charset,Bound,AttachNum,AttachType,AttachFile,MailBody)
Select @Identity1=Scope_Identity()", conn)
How can i store the value returned by Scope_Identity() to a variable so i can use is later on.