Error Trying to Delete File

K

Keith

I am trying to delete a file off a server (same server asp app is running
on). I have done this before and not encountered any problems.

The code I am using is:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath =
Server.MapPath("..\..\..\sections\ezine\editions\images\articlethumbs\")
ImagePath = ImagePath & "\" &
(RS_Content.Fields.Item("CON_Issue_Number").Value) & "\" &
(RS_Content.Fields.Item("CON_Image").Value)

However, I am getting an error pointing to the last line of code above:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

Can anyone offer any help please? I'm sure I am missing something simple
from staring at this so long.
 
B

Bob Barrows [MVP]

Keith said:
I am trying to delete a file off a server (same server asp app is
running on). I have done this before and not encountered any
problems.

The code I am using is:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath =
Server.MapPath("..\..\..\sections\ezine\editions\images\articlethumbs\")
ImagePath = ImagePath & "\" &
(RS_Content.Fields.Item("CON_Issue_Number").Value) & "\" &
(RS_Content.Fields.Item("CON_Image").Value)

However, I am getting an error pointing to the last line of code
above:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

Can anyone offer any help please? I'm sure I am missing something
simple from staring at this so long.

Debugging.

That last statement refers to several objects. You need to break them out
into their own statements so you can discover which one is causing the
error.

IssueNum= RS_Content.Fields.Item("CON_Issue_Number").Value
Image=RS_Content.Fields.Item("CON_Image").Value
ImagePath = ImagePath & "\" & IssueNum & "\" & Image

Incidently, this
RS_Content.Fields.Item("CON_Issue_Number").Value

could more succinctly be written as this:
RS_Content("CON_Issue_Number")

Some people prefer to explicitly name the value property to avoid getting
the Field object when they really want the value, but even they don't insist
on "Fields.Item"
Any reason you are being so verbose?

Bob Barrows
 
K

Keith

Bob Barrows said:
Debugging.

That last statement refers to several objects. You need to break them out
into their own statements so you can discover which one is causing the
error.

IssueNum= RS_Content.Fields.Item("CON_Issue_Number").Value
Image=RS_Content.Fields.Item("CON_Image").Value
ImagePath = ImagePath & "\" & IssueNum & "\" & Image

Incidently, this
RS_Content.Fields.Item("CON_Issue_Number").Value

could more succinctly be written as this:
RS_Content("CON_Issue_Number")

Some people prefer to explicitly name the value property to avoid getting
the Field object when they really want the value, but even they don't
insist
on "Fields.Item"
Any reason you are being so verbose?

Thanks

I have done that and now it fails with the same error on either of the lines
which call a field from the recordset.

Issue_Number contains a numeric value and Image contains text.

Any ideas?

I always refer to fields in the RS like this - no reason other than that's
just how I was learned to do it.
 
B

Bob Barrows [MVP]

Keith said:
I have done that and now it fails with the same error on either of
the lines which call a field from the recordset.
That tells me that the recordset is not available at this point. Either it's
closed, out of scope, BOF, or EOF. I think we need to see a little more code
to determine which is the case. Does

Response.write RS_Content.EOF

raise an error? Does it return true? Try BOF as well

Bob Barrows
 
K

Keith

Bob Barrows said:
That tells me that the recordset is not available at this point. Either
it's
closed, out of scope, BOF, or EOF. I think we need to see a little more
code
to determine which is the case. Does

Response.write RS_Content.EOF

raise an error? Does it return true? Try BOF as well

Bob Barrows

Both EOF and BOF are False - as I would expect as the Recordset has a record
in it.
 
B

Bob Barrows [MVP]

Keith said:
Both EOF and BOF are False - as I would expect as the Recordset has a
record in it.

That means the field names aren't correct. Do

for each fld in RS_Content.Fields
response.write fld.Name & ": """ & fld.value & """<BR>"
next

Bob Barrows
 
K

Keith

Bob Barrows said:
That means the field names aren't correct. Do

for each fld in RS_Content.Fields
response.write fld.Name & ": """ & fld.value & """<BR>"
next

Bob Barrows

It listed all my fields and their contents.

The ones in question:

CON_Issue_Number: "1"
CON_Image: "1.jpg"

This is what I expected.
 
K

Keith

Keith said:
It listed all my fields and their contents.

The ones in question:

CON_Issue_Number: "1"
CON_Image: "1.jpg"

This is what I expected.

Could this be a problem with the web server? And if so what?
 
B

Bob Barrows [MVP]

Keith said:
It listed all my fields and their contents.

The ones in question:

CON_Issue_Number: "1"
CON_Image: "1.jpg"

This is what I expected.

That is just bizarre. The loop runs with no error but referring to the same
field name explicitly throws an error??

Are you sure there's no typos in your code? I'm assuming you ran the loop at
the point in your code where the original error was occurring? Do this (I'm
clutching at straws here):

for each fld in RS_Content.Fields
response.write fld.Name & ": """ & fld.value & """<BR>"
next
on error resume next
Response.Write "RS_Content.Fields.Item(""CON_Issue_Number"").Value contains
"
Response.Write RS_Content.Fields.Item("CON_Issue_Number").Value
if err <> 0 then
response.write RS_Content(""CON_Issue_Number"").Value contains "
response.write RS_Content("CON_Issue_Number")
end if
Response.End
 
B

Bob Barrows [MVP]

Bob said:
Response.Write "RS_Content.Fields.Item(""CON_Issue_Number"").Value
contains "

Watch out for unintended line breaks. The above should all be on one line.
 
I

io

Keith said:
I am trying to delete a file off a server (same server asp app is running
on). I have done this before and not encountered any problems.

The code I am using is:

Set File = CreateObject("Scripting.FileSystemObject")
ImagePath =
Server.MapPath("..\..\..\sections\ezine\editions\images\articlethumbs\")
ImagePath = ImagePath & "\" &
(RS_Content.Fields.Item("CON_Issue_Number").Value) & "\" &
(RS_Content.Fields.Item("CON_Image").Value)

However, I am getting an error pointing to the last line of code above:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

Can anyone offer any help please? I'm sure I am missing something simple
from staring at this so long.

Make sure you do not set RS_Content to Nothing somewhere before that code.
It may be a bit hard to spot especially when you use #include with .asp(s)
that use same recordset identifier.
 
K

Keith

Still having problems here.

Everything I do shows that the recordset contains the correct values, but
the delete still gives me the following error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''
 
B

Bob Barrows [MVP]

Keith said:
Still having problems here.

Everything I do shows that the recordset contains the correct values,
but the delete still gives me the following error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

We are not going to be able to resolve this without having a way to
reproduce the problem. Strip your app to the bare essentials needed to
demonstrate the issue. Get rid of all non-essential html markup, etc.
Provide sql statements to create the table and insert the sample data into
the table. Post the repro script to the newsgroup and somebody will be able
to help you.

Bob Barrows
 
K

Keith

Bob Barrows said:
We are not going to be able to resolve this without having a way to
reproduce the problem. Strip your app to the bare essentials needed to
demonstrate the issue. Get rid of all non-essential html markup, etc.
Provide sql statements to create the table and insert the sample data into
the table. Post the repro script to the newsgroup and somebody will be
able
to help you.

I found a way around it.

I set a session variable at the start of the document, use them instead of
referenced to the recordset, and then empty them at the end.

Messy, but works!

I still have no idea why referencing the recordset is not working though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top