Updating record EOF

  • Thread starter Thread starter Ed Richter
  • Start date Start date
E

Ed Richter

I'm attempting to update a record. The query was working OK, however there are some situations where a person may have entered some incorrect data, thus not finding a matching record. In case that happend I added the EOF statement and have added some code below to take care of what to do. However as soon as I added the EOF, I got the following error about object being closed?? If the schObj object is closed, I can't understand how it was open one line prior, before I added the EOF statement. Can you not use EOF when updating? Something else casuing the error?

Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref = '" & ref_ID & "' WHERE (Sec_L_Name = '" & Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match & "# ) ")

line 221>> If schObj.EOF = true then


ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/sports_ref_ratings/rating_submit.asp, line 221
 
You need to check for the record prior to doing the update. If the record exist, then do the do the
update.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================


I'm attempting to update a record. The query was working OK, however there are some situations
where a person may have entered some incorrect data, thus not finding a matching record. In case
that happend I added the EOF statement and have added some code below to take care of what to do.
However as soon as I added the EOF, I got the following error about object being closed?? If the
schObj object is closed, I can't understand how it was open one line prior, before I added the EOF
statement. Can you not use EOF when updating? Something else casuing the error?

Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref = '" & ref_ID & "' WHERE
(Sec_L_Name = '" & Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match &
"# ) ")

line 221>> If schObj.EOF = true then


ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/sports_ref_ratings/rating_submit.asp, line 221
 
So just reverse the order of the two lines?

Do I first query for the record based on same criteria, if found execute the
update. If not found, then EOF? And by doing so, would place the EOF (and
query) ahead of the update?
 
I would do something like the following:

Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Current_schedule WHERE (Sec_L_Name = '" & Rater_last & "' AND Home = '" &
Home_team & "' AND G_Date = #" & Date_match & "# )"
objRS.Open strSQL, objConn

If Not objRS.EOF Then
Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref = '" & ref_ID & "' WHERE
(Sec_L_Name = '" & Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match &
"# ) ")
End If

objRS.close
Set objRS = nothing

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Or also add the no record found to inform the user

If Not objRS.EOF Then
Set schObj = objConn.Execute ("UPDATE ......
Else
response.write "No matching PBL Records were found"
End If


--




|I would do something like the following:
|
| Set objRS = Server.CreateObject("ADODB.Recordset")
| strSQL = "SELECT * FROM Current_schedule WHERE (Sec_L_Name = '" & Rater_last & "' AND Home = '" &
| Home_team & "' AND G_Date = #" & Date_match & "# )"
| objRS.Open strSQL, objConn
|
| If Not objRS.EOF Then
| Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref = '" & ref_ID & "' WHERE
| (Sec_L_Name = '" & Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match &
| "# ) ")
| End If
|
| objRS.close
| Set objRS = nothing
|
| --
| ==============================================
| Thomas A. Rowe (Microsoft MVP - FrontPage)
| WEBMASTER Resources(tm)
|
| FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| ==============================================
| To assist you in getting the best answers for FrontPage support see:
| http://www.net-sites.com/sitebuilder/newsgroups.asp
|
| | > So just reverse the order of the two lines?
| >
| > Do I first query for the record based on same criteria, if found execute the update. If not
| > found, then EOF? And by doing so, would place the EOF (and query) ahead of the update?
| >
| >
| >> You need to check for the record prior to doing the update. If the record exist, then do the do
| >> the update.
| >>
| >> --
| >> ==============================================
| >> Thomas A. Rowe (Microsoft MVP - FrontPage)
| >> WEBMASTER Resources(tm)
| >>
| >> FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| >> ==============================================
| >> To assist you in getting the best answers for FrontPage support see:
| >> http://www.net-sites.com/sitebuilder/newsgroups.asp
| >>
| >> | >> I'm attempting to update a record. The query was working OK, however there are some situations
| >> where a person may have entered some incorrect data, thus not finding a matching record. In case
| >> that happend I added the EOF statement and have added some code below to take care of what to do.
| >> However as soon as I added the EOF, I got the following error about object being closed?? If the
| >> schObj object is closed, I can't understand how it was open one line prior, before I added the
| >> EOF statement. Can you not use EOF when updating? Something else casuing the error?
| >>
| >> Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref = '" & ref_ID & "' WHERE
| >> (Sec_L_Name = '" & Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match &
| >> "# ) ")
| >>
| >> line 221>> If schObj.EOF = true then
| >>
| >>
| >> ADODB.Recordset error '800a0e78'
| >>
| >> Operation is not allowed when the object is closed.
| >>
| >> /sports_ref_ratings/rating_submit.asp, line 221
| >>
| >>
| >
| >
|
|
 
OK, that's what I thought you meant. Good idea?

Just curious though, I can understand how your suggestion would work, but
can you not use the EOF test in conjunction with a database update operation
like I tried to do?
 
Not that I am aware of, as a single process.

I normally test a single field, such as MemberID or AcctNo and not a group of fields, since I assign
unique ID for my projects and only use the ID field for deleting records.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Clarification:

"and only use the Access (Autonumber) ID field for deleting records."


--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Agreed, i've always used ID number (which is Auto number) for delete. That
usually works well!
 
OK now getting the following error

Microsoft OLE DB Service Components error '80040e73'

Format of the initialization string does not conform to the OLE DB
specification.

/sports_ref_ratings/rating_submit.asp, line 267

Set objRS = Server.CreateObject("ADODB.Connection")

strSQL = "SELECT * FROM Current_schedule WHERE (First_L_Name = '" &
Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match
& "# )"

line 267> objRS.Open strSQL, objConn
 
Ok, what type of connection are you using?

I always use a System DSN connection.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
You are setting the recordset as the connection
- the 2 are different

Set objRS = Server.CreateObject("ADODB.Connection")
should be
Set objRS = Server.CreateObject("ADODB.Recordset")

And prior to that you need to set and open objConn as say:

set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open YOURCONNECTIONNAMEHERE
--




| OK now getting the following error
|
| Microsoft OLE DB Service Components error '80040e73'
|
| Format of the initialization string does not conform to the OLE DB
| specification.
|
| /sports_ref_ratings/rating_submit.asp, line 267
|
| Set objRS = Server.CreateObject("ADODB.Connection")
|
| strSQL = "SELECT * FROM Current_schedule WHERE (First_L_Name = '" &
| Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match
| & "# )"
|
| line 267> objRS.Open strSQL, objConn
|
|
|
| | > Clarification:
| >
| > "and only use the Access (Autonumber) ID field for deleting records."
| >
| >
| > --
| > ==============================================
| > Thomas A. Rowe (Microsoft MVP - FrontPage)
| > WEBMASTER Resources(tm)
| >
| > FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| > ==============================================
| > To assist you in getting the best answers for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| >
| > | >> Not that I am aware of, as a single process.
| >>
| >> I normally test a single field, such as MemberID or AcctNo and not a
| >> group of fields, since I assign unique ID for my projects and only use
| >> the ID field for deleting records.
| >>
| >> --
| >> ==============================================
| >> Thomas A. Rowe (Microsoft MVP - FrontPage)
| >> WEBMASTER Resources(tm)
| >>
| >> FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| >> ==============================================
| >> To assist you in getting the best answers for FrontPage support see:
| >> http://www.net-sites.com/sitebuilder/newsgroups.asp
| >>
| >> | >>> OK, that's what I thought you meant. Good idea?
| >>>
| >>> Just curious though, I can understand how your suggestion would work,
| >>> but can you not use the EOF test in conjunction with a database update
| >>> operation like I tried to do?
| >>>
| >>>
| >>>
| >>> | >>>>I would do something like the following:
| >>>>
| >>>> Set objRS = Server.CreateObject("ADODB.Recordset")
| >>>> strSQL = "SELECT * FROM Current_schedule WHERE (Sec_L_Name = '" &
| >>>> Rater_last & "' AND Home = '" & Home_team & "' AND G_Date = #" &
| >>>> Date_match & "# )"
| >>>> objRS.Open strSQL, objConn
| >>>>
| >>>> If Not objRS.EOF Then
| >>>> Set schObj = objConn.Execute ("UPDATE Current_schedule SET Post_2nd_Ref
| >>>> = '" & ref_ID & "' WHERE (Sec_L_Name = '" & Rater_last & "' AND Home =
| >>>> '" & Home_team & "' AND G_Date = #" & Date_match & "# ) ")
| >>>> End If
| >>>>
| >>>> objRS.close
| >>>> Set objRS = nothing
| >>>>
| >>>> --
| >>>> ==============================================
| >>>> Thomas A. Rowe (Microsoft MVP - FrontPage)
| >>>> WEBMASTER Resources(tm)
| >>>>
| >>>> FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| >>>> ==============================================
| >>>> To assist you in getting the best answers for FrontPage support see:
| >>>> http://www.net-sites.com/sitebuilder/newsgroups.asp
| >>>>
| >>>> | >>>>> So just reverse the order of the two lines?
| >>>>>
| >>>>> Do I first query for the record based on same criteria, if found
| >>>>> execute the update. If not found, then EOF? And by doing so, would
| >>>>> place the EOF (and query) ahead of the update?
| >>>>>
| >>>>>
| >>>>> | >>>>>> You need to check for the record prior to doing the update. If the
| >>>>>> record exist, then do the do the update.
| >>>>>>
| >>>>>> --
| >>>>>> ==============================================
| >>>>>> Thomas A. Rowe (Microsoft MVP - FrontPage)
| >>>>>> WEBMASTER Resources(tm)
| >>>>>>
| >>>>>> FrontPage Resources, WebCircle, MS KB Quick Links, etc.
| >>>>>> ==============================================
| >>>>>> To assist you in getting the best answers for FrontPage support see:
| >>>>>> http://www.net-sites.com/sitebuilder/newsgroups.asp
| >>>>>>
| >>>>>> | >>>>>> I'm attempting to update a record. The query was working OK, however
| >>>>>> there are some situations where a person may have entered some
| >>>>>> incorrect data, thus not finding a matching record. In case that
| >>>>>> happend I added the EOF statement and have added some code below to
| >>>>>> take care of what to do. However as soon as I added the EOF, I got
| >>>>>> the following error about object being closed?? If the schObj object
| >>>>>> is closed, I can't understand how it was open one line prior, before
| >>>>>> I added the EOF statement. Can you not use EOF when updating?
| >>>>>> Something else casuing the error?
| >>>>>>
| >>>>>> Set schObj = objConn.Execute ("UPDATE Current_schedule SET
| >>>>>> Post_2nd_Ref = '" & ref_ID & "' WHERE (Sec_L_Name = '" & Rater_last &
| >>>>>> "' AND Home = '" & Home_team & "' AND G_Date = #" & Date_match & "# )
| >>>>>> ")
| >>>>>>
| >>>>>> line 221>> If schObj.EOF = true then
| >>>>>>
| >>>>>>
| >>>>>> ADODB.Recordset error '800a0e78'
| >>>>>>
| >>>>>> Operation is not allowed when the object is closed.
| >>>>>>
| >>>>>> /sports_ref_ratings/rating_submit.asp, line 221
| >>>>>>
| >>>>>>
| >>>>>
| >>>>>
| >>>>
| >>>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 
Back
Top