p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   updating table (http://p2p.wrox.com/showthread.php?t=19141)

markhardiman September 29th, 2004 05:29 AM

updating table
hi all
i have the following code

Set pb_RS=Server.CreateObject("ADODB.Recordset")
pb_SQL = "SELECT * FROM web_1 WHERE web_num= '" & SESSION("web_num") & "'"
pb_RS.Open pb_SQL, objConn, , adLockOptimistic

pb_RS.Fields("web_pb").value = SESSION("Valid")
pb_RS.Fields("web_pdate").value = Date
pb_RS.Fields("webr_stage").value = "Claimed"

Set pb_RS= Nothing

and i am trying to update a record already in a table. however when this code is run it changes the values for all records in the table. any ideas whats happening?


happygv September 29th, 2004 09:49 AM

Try to response.write SESSION("web_num"), and see if that hold any value.

A better way is to try this.

pb_SQL = "SELECT * FROM web_1 WHERE web_num= '" & SESSION("web_num") & "'"
Response.write pb_SQL
pb_RS.Open pb_SQL, objConn, , adLockOptimistic

Now copy/paste the resulting SQL statement and execute that on query analyser and see what it results, that would give you some idea on what is going wrong. Also confirm if you are using any Loop to do your update there.

Hope that helps.

- Vijay G
Strive for Perfection

iniro September 29th, 2004 12:35 PM

well if i was you i would have used update query to do the job. i find it easier to work with.


pb_SQL="update web_1 set web_pb ="' & session("Valid") & "',web_pdate='" & date & "',webr_stage=""Claimed"" where web_num='" & session("web_num") & "'"
pb_RS.open pb_sql,objConn

i think this should work

All times are GMT -4. The time now is 07:02 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.