Public Function getMyID() As Integer
Dim strConn As String = ConfigurationSettings.AppSettings("myDB")
Dim objConn As New OleDbConnection(strConn)
Dim strSQL As String = "SELECT the_id FROM the_database WHERE (email = '" & System.Web.HttpContext.Current.User.Identity.Name & "')"
Dim objCommand As New OleDbCommand(strSQL, objConn)
Dim sResult As Integer
objConn.Open()
sResult = CType(objCommand.ExecuteScalar(), Integer)
objConn.Close()
Return sResult
End Function
Now you can call another function or sub to increment getMyID() + 1 and send that value back to the database as a new row.
If you are using Access make sure Auto Increment isn't turned on.
|