#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Problems with FileSystemObject and ADO


    Hi guys,

    I'm trying to do a fairly basic count operation for my chatroom on NoFeeHost and I'm really stumped.

    After trying a few things, I realised that Server.CreateObject("Scripting.FileSystemObject") was failing every time. I just want to be able to read and write to a text file using Classic ASP.

    Assuming that I'm correct and that certain hosts (Jabry seems to possess an identical interface) only allow you to work with databases, could anyone tell me why the following code caused a 500 error?

    PHP Code:
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="MSDAOSP"
    conn.Open(Server.MapPath("db/sample.txt"))
    conn.Close
    %> 
    (It's the most basic version possible. Unfortunately, I've no experience with ADO and usually write my ASP code in JScript.)

    Apologies in advance if I'm not being descriptive enough but I think it's a fairly trivial problem. I just can't see what it is!

    Any help would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    If you can't open a text file with the FSO you probably won't have any better luck adding another layer of complexity with ADO. Most likely your file permissions are incorrect in the directory where the text file resides.

    If you posted the actual error message it might provide more insight. If you're using IE try turning off the "show friendly http errors" setting.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0
    Originally Posted by Doug G
    If you're using IE try turning off the "show friendly http errors" setting.
    Well that's something I didn't know about!

    Here's the error message:
    Provider error '80040e21'

    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

    /twcfpages/vb.asp, line 13
    Seeing as I'd rather avoid ADO altogether, matching these two up might be more useful:

    PHP Code:
    <%@ language="javascript" %>
    <
    html>
    <
    head>
    </
    head>
    <
    body>

    <%

    var 
    filepath Server.MapPath("db/sample.txt")
    var 
    filesystem Server.CreateObject("Scripting.FileSystemObject")
    var 
    instream filesystem.OpenTextFile(filepath1true)
    Response.Write(instream.ReadLine())
    instream.Close()

    %>
    </
    body>
    </
    html
    Server object error 'ASP 0177 : 800401f3'

    Server.CreateObject Failed

    /twcfpages/test.asp, line 10

    800401f3
  6. #4
  7. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    In ado this error generally happens becase your sql does something that isn't allowed by the drivers. For example, you can get this error when using ODBC drivers and you reference BLOB fields in an incorrect order in your sql query.

    I'm not familiar wiht the ado text driver, I don't know what might be wrong to get the multi-step error.

    For the 2nd part, assuming line 10 is your fso createobject statement, are you sure you have the filesystem object installed and available to your website? Many hosts disable fso for security reasons.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0
    Originally Posted by Doug G
    For the 2nd part, assuming line 10 is your fso createobject statement, are you sure you have the filesystem object installed and available to your website? Many hosts disable fso for security reasons.
    Yeah, that's what I figured. There's no real documentation provided but I gleaned from the hosting FAQ that databases, at least, were supported.

    Do you have any tips on the best way to convert my textfile system into ADO? I don't think I have any software that generates .mdb files but I'm sure there's a way around that. Definitely should be easier to figure out with friendly errors disabled.
  10. #6
  11. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    Start with setting up a directory on your server where your web server user has write and create file permissions. How you do this varies from host to host.

    For a quick test of permissions, you could throw together a quick page that gets an ado recordset from a db and use recordset.save to an xml file. If it works and the file gets created your permissions are probably good.

    Then visit the microsoft documentation, there is an ADO text driver but I don't know how to use it. MS does have very thorough and complete documentation though, once you find the proper section in the library read up on using the ado text driver.

    I'd ask the host if the filesystem object is available first, it would probably be much simpler a solution than ado. The filesystem object documentation is somewhere in the MS vbscript documentation.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0
    Originally Posted by Doug G
    Then visit the microsoft documentation, there is an ADO text driver but I don't know how to use it. MS does have very thorough and complete documentation though, once you find the proper section in the library read up on using the ado text driver.
    Got it. Unfortunately...

    Note You'll notice that we keeping talking about reading text files, and never say anything about writing to text files. Why? Well, unfortunately, the ODBC Text Driver (which is what we're using here) can only read from files; it can't write to them. To write to a text file, you'll have to use the FileSystemObject or something similar.


    The main problem is that I'm restricted to using free hosting and NoFeeHost (understandably) don't offer any technical support to users. I'll try one more time to find a better host and then tell my members it's not happening.

    Thanks for all your help!

IMN logo majestic logo threadwatch logo seochat tools logo