Error Trying to Delete File

Discussion in 'ASP General' started by Keith, Jan 20, 2005.

  1. Keith

    Keith Guest

    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.
     
    Keith, Jan 20, 2005
    #1
    1. Advertising

  2. Keith wrote:
    > 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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #2
    1. Advertising

  3. Keith

    Keith Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:OqOEKYv$...
    > Keith wrote:
    >> 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?
    >


    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.
     
    Keith, Jan 20, 2005
    #3
  4. Keith wrote:
    >
    > 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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #4
  5. Keith

    Keith Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:%23Mx1$pv$...
    > Keith wrote:
    >>
    >> 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


    Both EOF and BOF are False - as I would expect as the Recordset has a record
    in it.
     
    Keith, Jan 20, 2005
    #5
  6. Keith wrote:
    > "Bob Barrows [MVP]" <> wrote in message
    > news:%23Mx1$pv$...
    >> Keith wrote:
    >>>
    >>> 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

    >
    > 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

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #6
  7. Keith

    Keith Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:O25%23VJw$...
    > Keith wrote:
    >> "Bob Barrows [MVP]" <> wrote in message
    >> news:%23Mx1$pv$...
    >>> Keith wrote:
    >>>>
    >>>> 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

    >>
    >> 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


    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.
     
    Keith, Jan 20, 2005
    #7
  8. Keith

    Keith Guest

    "Keith" <@.> wrote in message news:O22ZpNw$...
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:O25%23VJw$...
    >> Keith wrote:
    >>> "Bob Barrows [MVP]" <> wrote in message
    >>> news:%23Mx1$pv$...
    >>>> Keith wrote:
    >>>>>
    >>>>> 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
    >>>
    >>> 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

    >
    > 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?
     
    Keith, Jan 20, 2005
    #8
  9. Keith wrote:
    > "Bob Barrows [MVP]" <> wrote in message
    > news:O25%23VJw$...
    >> Keith wrote:
    >>> "Bob Barrows [MVP]" <> wrote in message
    >>> news:%23Mx1$pv$...
    >>>> Keith wrote:
    >>>>>
    >>>>> 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
    >>>
    >>> 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

    >
    > 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

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #9
  10. Keith wrote:
    > "Keith" <@.> wrote in message
    > Could this be a problem with the web server? And if so what?

    None that I have ever encountered.
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #10
  11. Bob Barrows [MVP] wrote:
    > 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.
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 20, 2005
    #11
  12. Keith

    io Guest

    "Keith" <@.> wrote in message news:#aI0o1u$...
    > 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.
     
    io, Jan 21, 2005
    #12
  13. Keith

    Keith Guest

    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: ''
     
    Keith, Jan 25, 2005
    #13
  14. Keith wrote:
    > 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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 25, 2005
    #14
  15. Keith

    Keith Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > Keith wrote:
    >> 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.
    >


    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.
     
    Keith, Jan 25, 2005
    #15
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    381
  2. Viewer T.
    Replies:
    2
    Views:
    1,142
    Jay Loden
    Jul 14, 2007
  3. MRAB
    Replies:
    5
    Views:
    262
  4. Carl Graff
    Replies:
    0
    Views:
    175
    Carl Graff
    Oct 13, 2006
  5. mikie
    Replies:
    2
    Views:
    83
    Steven D'Aprano
    Mar 24, 2014
Loading...

Share This Page