Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update field held in variable.

Status
Not open for further replies.

struth

Programmer
Aug 26, 2001
114
GB
Hi

I am just writing an update that works with various parameters and variables and I don't know how to get this update routine to update just the one field. I have tried as follows but it doesn't work.

Set db = Session("db")
Set rsUpdate = Session("rs")
sTableName = Session("sTableName")
sOK = Session("svOK")
sKey = Session("pKey")


sSQL = "SELECT * FROM " & sTableName & " WHERE " & sKey & " = " & Request.QueryString("record")


set rsUpdate = Server.CreateObject("ADODB.Recordset")
rsUpdate.Open sSQL, db, adOpenDynamic, adLockOptimistic, adCmdText


*****How do I get it to update the field held in the parameter sOK --

rsUpdate.Fields("sOK") ="1"

rsUpdate.Update


TIA
Struth
"It's life Jim, but not as we know it!"
 
If I remember correctly you can't update fields in a subset of the table, you could, on the other hand, write an update statment that updated all records that met the criteria above:
Code:
sSQL = "UPDATE " & sTableName & "Set sOK = '1' WHERE " & sKey & " = " & Request.QueryString("record")
That would update the sOK field to "1" for all records that had sKey = your querystring value.

-Tarwn "If you eat a live toad first thing in the morning, nothing worse will happen all day long." - California saying
"To you or the toad" - Niven's restatement of California saying
"-well most of the time anyway..." - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Correction, i missed a spcae:
Code:
sSQL = "UPDATE " & sTableName & " Set sOK = '1' WHERE " & sKey & " = " & Request.QueryString("record")


"If you eat a live toad first thing in the morning, nothing worse will happen all day long." - California saying
"To you or the toad" - Niven's restatement of California saying
"-well most of the time anyway..." - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Thanks Tarwn

That seems to have sent me in the right direction

Thanks "It's life Jim, but not as we know it!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top