Finding the autoid number of a sql insert query (.net frameowork)
Posted on 2003-11-05
is it possible to find the autoincrement id of a record that has been inserted without doing another call to the database. I need to be able to do this in asp.net.
Here is an example:
The table consists of three columns; id (autoincrement), username, password
Dim oConn As sqlConnection
Dim oCmd As sqlCommand
Dim SQLQuery As String
SQLQuery = "INSERT INTO TB_Names "
SQLQuery = " (username, password) " & _
oCmd = new SqlCommand(SQLQuery)
oCmd.Connection = oConn
surely there should be something like oCmd.max(id)