microsoft.public.dotnet.framework.aspnet

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

In normal asp i used
---------

objRS.Open "tbl_Nieuws", objConn, 1, 3
objRS.AddNew

objRS.Fields("N_Datum") = FormatDateTime(Now(),2)
objRS.Fields("N_Title") = ReplaceHTML(Upload.Form("title"))
objRS.Fields("N_Intro") = ReplaceHTML(Upload.Form("intro"))
objRS.Fields("N_Body") = ReplaceHTML(Upload.Form("body"))
objRS.Fields("N_UserID") = Upload.Form("id")
objRS.Fields("N_Image") = file.Filename
objRS.Fields("N_Ip") = strIP
objRS.Fields("N_Deleted") = 0

objRS.Update
IntID = objRS("N_ID")
objRS.Close

---------
to get the id of the record i just added.
in asp.net i have this but i dont know how i can accomplish the same and
wanted to know if there
is some easyway for it.

-----------------

Dim myConnection As New SqlConnection(AppSettings("DatabaseCon"))
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 MyCommand As New SqlCommand(strSQL, myConnection)
myConnection.Open()
MyCommand.ExecuteNonQuery()
myConnection.Close()

--------------
i want the auto-id (i called my autoid U_ID) of the record i just added to
the tbl_Users. How 2? thats
the question.

thx in advance,

Richard
 
Sorry i copied the title wrong, Anyway the title should be:
"Getting the Id of the record i just added"

Richard
 
Back
Top