Jump to content

How to go to the BOF....


wilsonf1

Recommended Posts

Hi i have some ASP and SQL code that read froms my events DB - it checks the event date, and if the date has passed, it updates it to a date wildy in the future, which i then display on the page as an event TBA..... this means only forthing coming event dates get show and the rest are tba....now the script updates my database in the loop with the wild future date if the event has passed, the only problem is, as the loop continues and the info gets displayed, it wont read the fact that i may have just updated one of the fields to the wild date - so the first time the update is done, it wont get displayed on the page, the 2nd time you reload the page, it knows the date has changed.my question is, during this IF and UPDATE part of my script, can i make it read that row again to make sure it response.writes out the new information? horribly explained i know, perhaps my code below can help?

Set databaseConnection = Server.CreateObject("ADODB.Connection")				databaseConnection.Provider="Microsoft.Jet.OLEDB.4.0"				databaseConnection.Open = Server.MapPath("backoffice/data/pages.mdb")								set rs = Server.CreateObject("ADODB.recordset")										rs.Open "SELECT * FROM pages ORDER BY first_date", databaseConnection				Do While Not rs.EOF									id =  rs.fields("id")					first_date =  rs.fields("first_date")														[b]If first_date < date() Then											insertSQL = "UPDATE pages SET first_date = '01/01/2111' WHERE id="& id &" "						DatabaseConnection.Execute insertSQL, adLockPessimistic[/b]											Elseif first_date = "01/01/2111" Then											first_date = "tba"											End If

Link to comment
Share on other sites

[...] my question is, during this IF and UPDATE part of my script, can i make it read that row again to make sure it response.writes out the new information? [...]
Personally I would not try and do it all during one pass. I would do a first pass for the update, and then close and reopen the recordset to do a second pass for display (a second loop). If you decide to do this, then your BOF question is not needed, but just in case, I seem to remember it depends on which MDAC (etc) version you're using, and how you've opened the recordset, but rs.MoveFirst probably does it.Also personally I would not change the date, but instead add a new status field, but maybe you don't have the freedom to add a column to the table for that.
Link to comment
Share on other sites

Personally I would not try and do it all during one pass. I would do a first pass for the update, and then close and reopen the recordset to do a second pass for display (a second loop). If you decide to do this, then your BOF question is not needed, but just in case, I seem to remember it depends on which MDAC (etc) version you're using, and how you've opened the recordset, but rs.MoveFirst probably does it.Also personally I would not change the date, but instead add a new status field, but maybe you don't have the freedom to add a column to the table for that.
good reply and 3 great points - if i do 2 loops - the first can check the date... then update the new status field which i can add no problem, then 2nd loop then checks the status column and response writes any forthcoming events......cheers Mr Reg Edit, hopefully i can do all of this
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...