Hi Justin,
You'll want to use ExecuteScalar() as shown in this article about one third
of the way down:
http://dotnetadvisor.net/doc/13279
Here's the relevant VB code:
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim dbConn As SqlConnection
' Create a new connection object pointing to
the database
dbConn = New SqlConnection("server=.;uid=sa;pwd=
;database=Northwind")
Dim dbComm As New SqlCommand()
dbComm.Connection = dbConn
dbComm.CommandType = CommandType.Text
dbComm.CommandText = "INSERT INTO Categories
(CategoryName, Description) " & _
"VALUES ('Guitars','Here you can find just the " & _
"guitar you looked for'); SELECT @@IDENTITY As 'Identity'"
Dim iID As Integer
Try
dbConn.Open()
iID = dbComm.ExecuteScalar()
Catch ex As Exception
Response.Write(ex.Message)
Response.End
Finally
If dbConn.State = ConnectionState.Open Then
dbConn.Close()
End If
End Try
Response.Write("The ID of the new record is: "
& iID.ToString())
End Sub
</script>
</html>