cactus1000
Programmer
I've never done this before, but Im trying to allow people to update their own records on an access database. I have a form that allows them to type in their first and last name. On submit, the asp code is supposed to find the record with their name and update the contents of a field called "alreadyformed" to "yes"
I keep getting an error message:Operation is not allowed when the object is closed.
I suppose they mean the recordset object, but I don't know what I'm doing wrong. Here's the code:
<%@ Language=VBScript %>
<html><body>
<%
dim objdc, cmdTmp, objrs
set objdc = Server.CreateObject("ADODB.Connection"
set cmdTmp = Server.CreateObject("ADODB.Command"
set objrs = Server.CreateObject("ADODB.Recordset"
objDC.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("carpool.mdb" & ";"
dim strlastname
strlastname = Request.Form("lastname"
dim strfirstname
strfirstname = Request.Form("firstname"
cmdTmp.ActiveConnection = objdc
cmdtmp.CommandText = "UPDATE table1 SET alreadyformed = yes WHERE lastname = '" & strlastname &"' and firstname = '" & strfirstname &"' ;"
objrs.Open cmdTmp,,1,3
if objrs.EOF then
Response.Write"<b>There are no records responding to your search</b><br><br><br>"
End If
%>
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
%>
I keep getting an error message:Operation is not allowed when the object is closed.
I suppose they mean the recordset object, but I don't know what I'm doing wrong. Here's the code:
<%@ Language=VBScript %>
<html><body>
<%
dim objdc, cmdTmp, objrs
set objdc = Server.CreateObject("ADODB.Connection"
set cmdTmp = Server.CreateObject("ADODB.Command"
set objrs = Server.CreateObject("ADODB.Recordset"
objDC.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("carpool.mdb" & ";"
dim strlastname
strlastname = Request.Form("lastname"
dim strfirstname
strfirstname = Request.Form("firstname"
cmdTmp.ActiveConnection = objdc
cmdtmp.CommandText = "UPDATE table1 SET alreadyformed = yes WHERE lastname = '" & strlastname &"' and firstname = '" & strfirstname &"' ;"
objrs.Open cmdTmp,,1,3
if objrs.EOF then
Response.Write"<b>There are no records responding to your search</b><br><br><br>"
End If
%>
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
objdc.Close
Set objdc = Nothing
%>