Click to See Complete Forum and Search --> : ASP Update statement


chrscote
01-26-2009, 10:40 AM
First off, it has been a while since I've coded any ASP, so the question I have may seem pretty basic. I have a form in which I am displaying the current values in a database. When the user edits one of the fields and clicks the Update button, I have an ASP page that takes in all of the pertinent data and is supposed to use and Update statement to update the database. However, I think I may be using the Update statement wrong. Here is my code:


set rsShips=Server.CreateObject("ADODB.Recordset")
if Request.Form("update")<>"" then
id = Request.Form("id")
hullNum = Request.Form("hullNum")
hullName = Request.Form("hullName")
shipClass = Request.Form("shipClass")
dim updateSql
updateSql = "Update dbo_tblHull SET Hull_Number="&hullNum&", hullName='"&hullName&"', classId="&shipClass&" WHERE HullID="&id
rsShips.Open updateSql
end if
'More code to get the latest values of all the fields

However, when I change the values in the form and hit Update, I get the original values displayed back in the form.

I have a feeling that it has to do with the last statement in the code since I have run the updateSql query in Access and it works fine.

Chris

buntine
01-26-2009, 04:50 PM
Just call "execute" function on your ADO database connection object. :)

The UPDATE statement does not return a recordset, therefore you don't need an ADO RecordSet object.

Cheers.

chrscote
01-27-2009, 08:43 AM
I knew there was something I was forgetting. Thanks for the help.

Now I have another issue related to this item. After clicking the Update button, the database is updating, but if I go to the next record then back to the one that was updated, it shows the data that was in the fields before the update. It looks as though it is just a cache issue, but I'm not sure how to have the browser reload the page instead of taking it from cache.


Chris