Click to See Complete Forum and Search --> : Updating SQL Database Problem


bills249
12-20-2006, 12:27 PM
I have created a set of pages to update/edit previous entries in a SQL database. Page 1 displays all of the data with a button for each record that when selected takes the user to page 2 where they can update/edit a couple of the fields in that record. Upon update the user is taken to page 3 where the update is confirmed. Everything is working as far as the updating is concerned. The problem is whenever the button on page 1 is selected, it pulls up the data that was there previously from an update of another record, not the current data from the database for that particular record. I have done numerous searches and haven't seen problem . Can someone help? :)

Below is the code from Page 2.

<%
OELID=Request.Form("OELID")
if OELID="" then response.end

set conn=Server.CreateObject("ADODB.Connection")

conn.Open "Provider=SQLOLEDB; Data Source = *********; Initial Catalog = *********; User Id = ********; Password=*******"

set rs = Server.CreateObject("ADODB.Recordset")
rs.open "SELECT tblOELog.OELID, tblOELog.Cause, tblOELog.CorrectiveAction FROM tblEmissionSources INNER JOIN tblOELog ON tblEmissionSources.EmissionSourceID = tblOELog.EmissionSourceID INNER JOIN tblInspector ON tblOELog.InspectorID = tblInspector.InspectorID INNER JOIN tblVENormal ON tblOELog.NormalID = tblVENormal.VENormalID INNER JOIN tblWeatherCond ON tblOELog.WeatherCondID = tblWeatherCond.WeatherCondID ORDER BY tblOELog.[Date] DESC, tblOELog.ObsDate DESC, tblOELog.ObsTime DESC",conn
%>
<html>
<head>
<title>Opacity Emission Log - Cause/Corrective Action Update Page</title>
</head>
<body>
<h2>Opacity Emission Log - Cause/Corrective Action Update Page</h2>
<form method="post" action="Page3.asp" target="_blank">
<input name="OELID" type="hidden" value=<%=OELID%>>
<table bgcolor="#b0c4de">
<%
for each x in rs.Fields
if x.name <> "OELID" and x.name <> "DateRevised" then%>
<tr>
<td><%=x.name%> </td>
<td><input name="<%=x.name%>" value="<%=x.value%>" size="75"></td>
<%end if
next

rs.close
set rs=nothing
conn.close
set conn=nothing
%>


</tr>
</table>
<br />
<input type="submit" name="action" value="Save">
<input type="submit" name="action" value="Delete">
</form>

</body>
</html>

russell
12-20-2006, 01:43 PM
put this at the top of all 3 pages, right after the opening script tag ( <% )
Response.ExpiresAbsolute = Date()-1

bills249
12-20-2006, 02:34 PM
Thanks for the input. I managed to find the root cause of the problem, ME!! :o I forgot a little piece of my SQL statement that told it which record to get,

WHERE tblOELog.OELID = '" & OELID & "'

Thanks again for the quick response.