R
Richard
Once a user clicks on the "add" button it adds the new record to the DB but
i want at the same time to get the primarykey of the record i just added. Is
this possible without writing a new "SELECT * bla bla"? and if so, how 2?
thx in advance,
Richard
My code
-----------------
Dim strSQL As String = "insert into tbl_Users" & _
"(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code,
U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned,
U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _
"values('"& tbGebruikersNaam.Text & "'," & _
"'"& tbWachtwoord.Text & "'," & _
"'"& tbEmailAdres.Text & "'," & _
""& strKlantenNR &"," & _
"'"& i & "'," & _
"1," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'no_avatar.gif'," & _
"'"& strIP & "'," & _
"0," & _
"0," & _
"'"& strMSN & "')"
Dim intID As Integer
Dim MyCommand As New SqlCommand(strSQL, myConnection)
myConnection.Open()
MyCommand.ExecuteNonQuery()
myConnection.Close()
------
i want at the same time to get the primarykey of the record i just added. Is
this possible without writing a new "SELECT * bla bla"? and if so, how 2?
thx in advance,
Richard
My code
-----------------
Dim strSQL As String = "insert into tbl_Users" & _
"(U_Username, U_Password, U_Email, U_KlantenNR, U_Auth_Code,
U_ToegangsID, U_Registered_On, U_Posts, U_Last_Logged_In, U_Banned,
U_Avatar, U_IP, U_Active, U_Deleted, U_MSN)" & _
"values('"& tbGebruikersNaam.Text & "'," & _
"'"& tbWachtwoord.Text & "'," & _
"'"& tbEmailAdres.Text & "'," & _
""& strKlantenNR &"," & _
"'"& i & "'," & _
"1," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'"& DateTime.Now.ToString("MM'-'dd'-'yyyy HH':'mm':'ss") &"'," & _
"0," & _
"'no_avatar.gif'," & _
"'"& strIP & "'," & _
"0," & _
"0," & _
"'"& strMSN & "')"
Dim intID As Integer
Dim MyCommand As New SqlCommand(strSQL, myConnection)
myConnection.Open()
MyCommand.ExecuteNonQuery()
myConnection.Close()
------