Dim myCommand As SqlCommand = conn.CreateCommand()
myCommand.CommandText = "INSERT INTO SBKBSearchLog (UserID) " & _
"VALUES (@UserID); SELECT SCOPE_IDENTITY() ;"
myCommand.Parameters.Add("@UserID", SqlDbType.Int).Value = userID
Dim searchID As Integer = myCommand.ExecuteScalar
Friday, March 12, 2010
Getting an ID from insert
Here is an example of getting an id from an insert. For scalability put it in a transaction block.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment