Closed Thread Icon

Topic awaiting preservation: recordset help (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12562" title="Pages that link to Topic awaiting preservation: recordset help (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: recordset help <span class="small">(Page 1 of 1)</span>\

 
wealoon
Nervous Wreck (II) Inmate

From: -
Insane since: Jun 2002

posted posted 12-24-2002 16:49

hi.
i want to ask about updating and deleting records from database using recordset method instead of sql method. I using asp and flash.


am i correct to write like this for update?


struserID = Request("currentUserID")
strconID = Request("currentContactID")
strFname = Request("newFname")
strLname = Request("newLname")
strphone = Request("newphone")
stremail = Request("newemail")
straddress = Request("newaddress")
strfax = Request("newfax")
strcompany = Request("newcompany")
strnotes = Request("newnotes")


'create the database connection
Set oConn = Server.CreateObject("ADODB.Connection")
'open the database
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/0search001/database02.mdb")

'open the recordset
Set oRs = Server.CreateObject("ADODB.Recordset")

strSql = "Select * From Contacts Where UserID= " & struserID & " AND ContactID = "strconID" "

oRs.Open strSql,oConn,1,3

If oRs.EOF Then

Response.write ("updatego=false")
else

oRs("FirstName") = strFname
oRs("LastName") = strLname
oRs("PhoneNum") = strphone
oRs("Email") = stremail
oRs("Address") = straddress
oRs("FaxNum") = strfax
oRs("Company") = strcompany
oRs("Notes") = strnotes
oRs.Update
Response.write ("updatego=true")
end if

oRs.Close
oConn.Close

and this for delete?

strconid = Request("currentContactID")
strFname = Request("newFname")
strLname = Request("newLname")
struserID = Request("currentUserID")

'create the database connection
Set oConn = Server.CreateObject("ADODB.Connection")
'open the database
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/0calendar001/database02.mdb")

'open the recordset
Set oRs = Server.CreateObject("ADODB.Recordset")

strSql = "Select * From Contacts Where FirstName='"& strFname & "' " & " And LastName= '" & strLname & "' And UserID= " & struserID & " AND ContactID = "strconID" "

oRs.Open strSql,oConn,1,3

If oRs.EOF Then

Response.write ("deletego=false")
else
oRs.Delete
Response.write ("deletego=true")
end if

oRs.Close
oConn.Close



-

fizgig
Nervous Wreck (II) Inmate

From: West Bloomfield MI
Insane since: Aug 2001

posted posted 01-02-2003 19:35

the update looks good, i usually just oConn.Execute SQL to delete, i know there are parameters like adAffectCurrent you need to pass to a delete in VB, not sure about the script, it may be 1 or 0

« BackwardsOnwards »

Show Forum Drop Down Menu