How does the code below work? I’ve never seen an UPDATE done this way. I always do it this way:
http://www.w3schools.com/sql/sql_update.asp
sqlText = "SELECT * FROM pricing WHERE pid=1"
rsx.Open sqlText, cnx, 1, 2
if Not rsx.EOF then
rsx("new_us") = Request.Form("new_us")
rsx("new_us_desc") = Rtrim(Request.Form("new_us_desc"))
rsx("new_ca") = Request.Form("new_ca")
rsx("new_ca_desc") = Rtrim(Request.Form("new_ca_desc"))
rsx("new_int") = Request.Form("new_int")
rsx("new_int_desc") = Rtrim(Request.Form("new_int_desc"))
rsx("conv_us") = Request.Form("conv_us")
rsx("conv_us_desc") = Rtrim(Request.Form("conv_us_desc"))
rsx("conv_ca") = Request.Form("conv_ca")
rsx("conv_ca_desc") = Rtrim(Request.Form("conv_ca_desc"))
rsx("conv_int") = Request.Form("conv_int")
rsx("conv_int_desc") = Rtrim(Request.Form("conv_int_desc"))
rsx("ren_us") = Request.Form("ren_us")
rsx("ren_us_desc") = Rtrim(Request.Form("ren_us_desc"))
rsx("ren_ca") = Request.Form("ren_ca")
rsx("ren_ca_desc") = Rtrim(Request.Form("ren_ca_desc"))
rsx("ren_int") = Request.Form("ren_int")
rsx("ren_int_desc") = Rtrim(Request.Form("ren_int_desc"))
rsx.Update
end if
rsx.Close
cnx.Close
Set rsx = Nothing
Set cnx = Nothing
Thanks
Brett
First you execute the query with
rsx.Open.cnxis the connection to the db, parameter value 1 isCursorType = adOpenKeysetand parameter value 2 isLockType = adLockPessimistic.rsxis aRecordset(com object) that holds the returned rows.if Not rsx.EOF thenchecks that you actually got at least one row, otherwise the edit will fail.This
rsx("new_us") = Request.Form("new_us")assign new values to fields in theRecordset.Finally
rsx.Updatesaves the modified fields to the db. The OLE DB Provider used bycnxbuilds the update statement that is sent to the database.So basic work flow is: