Cannot open Access database in ASP

Discussion in 'ASP General' started by xg, Mar 19, 2006.

  1. xg

    xg Guest

    Hi, I am writing an ASP page which contains the following code:

    var MM_DBConn=Server.CreateObject("ADODB.Connection");
    MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\trio.mdb;"); // failed on this line
    //MM_editQuery is an INSERT sql statement
    MM_DBConn.Execute(MM_editQuery);

    When I run this on a Windows 2000 Professional system, I got the following
    error:

    Microsoft JET Database Engine error '80004005'

    Not a valid file name.

    And it points out that it failed on the MM_DBConn.Open statement.

    However, if I copy the above code to a Visual Basic 6.0 form (on the same
    machine) like this:

    Private Sub Command1_Click()
    Dim o As Object
    Dim rs As Object

    Set o = CreateObject("adodb.connection")
    Call o.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\trio.mdb")
    Set rs = o.execute("select count(*) from comments")

    End Sub

    Everything works. Can someone tell me what went wrong? Thanks!

    xg
     
    xg, Mar 19, 2006
    #1
    1. Advertising

  2. xg

    Mike Brind Guest

    xg wrote:
    > Hi, I am writing an ASP page which contains the following code:
    >
    > var MM_DBConn=Server.CreateObject("ADODB.Connection");
    > MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\trio.mdb;"); // failed on this line
    > //MM_editQuery is an INSERT sql statement
    > MM_DBConn.Execute(MM_editQuery);
    >
    > When I run this on a Windows 2000 Professional system, I got the following
    > error:
    >
    > Microsoft JET Database Engine error '80004005'
    >
    > Not a valid file name.
    >
    > And it points out that it failed on the MM_DBConn.Open statement.
    >
    > However, if I copy the above code to a Visual Basic 6.0 form (on the same
    > machine) like this:
    >
    > Private Sub Command1_Click()
    > Dim o As Object
    > Dim rs As Object
    >
    > Set o = CreateObject("adodb.connection")
    > Call o.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\trio.mdb")
    > Set rs = o.execute("select count(*) from comments")
    >
    > End Sub
    >
    > Everything works. Can someone tell me what went wrong? Thanks!
    >
    > xg


    You have an extra semicolon after the closing parenthesis, after your
    connection string. It should look like this:

    MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\trio.mdb;")

    You'll also need to do the same on the following line:

    MM_DBConn.Execute(MM_editQuery)

    --
    Mike Brind
     
    Mike Brind, Mar 19, 2006
    #2
    1. Advertising

  3. xg wrote:
    > Hi, I am writing an ASP page which contains the following code:
    >
    > var MM_DBConn=Server.CreateObject("ADODB.Connection");
    > MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\trio.mdb;"); // failed on this line
    > //MM_editQuery is an INSERT sql statement
    > MM_DBConn.Execute(MM_editQuery);
    >
    > When I run this on a Windows 2000 Professional system, I got the
    > following error:
    >
    > Microsoft JET Database Engine error '80004005'
    >
    > Not a valid file name.
    >


    This is most likely a permissions problem. If your website is using
    Anonymous access, then the IUSR_machinename account needs to be granted
    Change permissions for the folder containing your database file (which
    probably should be located in a subfolder, not in the root).
    http://www.aspfaq.com/show.asp?id=2009

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Mar 19, 2006
    #3
  4. permissions probably

    http://www.powerasp.com/content/new/windows_2003_server_and_permissions.asp

    http://www.powerasp.com/content/new/windows_xp_pro_and_permissions.asp


    "Mike Brind" <> wrote in message
    news:...
    >
    > xg wrote:
    >> Hi, I am writing an ASP page which contains the following code:
    >>
    >> var MM_DBConn=Server.CreateObject("ADODB.Connection");
    >> MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    >> Source=c:\trio.mdb;"); // failed on this line
    >> //MM_editQuery is an INSERT sql statement
    >> MM_DBConn.Execute(MM_editQuery);
    >>
    >> When I run this on a Windows 2000 Professional system, I got the
    >> following
    >> error:
    >>
    >> Microsoft JET Database Engine error '80004005'
    >>
    >> Not a valid file name.
    >>
    >> And it points out that it failed on the MM_DBConn.Open statement.
    >>
    >> However, if I copy the above code to a Visual Basic 6.0 form (on the same
    >> machine) like this:
    >>
    >> Private Sub Command1_Click()
    >> Dim o As Object
    >> Dim rs As Object
    >>
    >> Set o = CreateObject("adodb.connection")
    >> Call o.open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    >> Source=c:\trio.mdb")
    >> Set rs = o.execute("select count(*) from comments")
    >>
    >> End Sub
    >>
    >> Everything works. Can someone tell me what went wrong? Thanks!
    >>
    >> xg

    >
    > You have an extra semicolon after the closing parenthesis, after your
    > connection string. It should look like this:
    >
    > MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\trio.mdb;")
    >
    > You'll also need to do the same on the following line:
    >
    > MM_DBConn.Execute(MM_editQuery)
    >
    > --
    > Mike Brind
    >
     
    Kyle Peterson, Mar 20, 2006
    #4
  5. xg

    xg Guest

    Thanks everyone. I grant the "Modify" permission of
    "c:\inetpub\wwwroot\triomotors\" for user "IUSR_DESKTOP" and the code now
    looks like this:

    var MM_DBConn=Server.CreateObject("ADODB.Connection");
    MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source=c:\inetpub\wwwroot\triomotors\trio.mdb;");
    MM_DBConn.Execute(MM_editQuery);

    I still get the same error message. Please help. Thanks!

    xg

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > xg wrote:
    > > Hi, I am writing an ASP page which contains the following code:
    > >
    > > var MM_DBConn=Server.CreateObject("ADODB.Connection");
    > > MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    > > Source=c:\trio.mdb;"); // failed on this line
    > > //MM_editQuery is an INSERT sql statement
    > > MM_DBConn.Execute(MM_editQuery);
    > >
    > > When I run this on a Windows 2000 Professional system, I got the
    > > following error:
    > >
    > > Microsoft JET Database Engine error '80004005'
    > >
    > > Not a valid file name.
    > >

    >
    > This is most likely a permissions problem. If your website is using
    > Anonymous access, then the IUSR_machinename account needs to be granted
    > Change permissions for the folder containing your database file (which
    > probably should be located in a subfolder, not in the root).
    > http://www.aspfaq.com/show.asp?id=2009
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    xg, Mar 20, 2006
    #5
  6. It's got nothing to do with your problem, but you really should put the
    folder containing the database outside of the wwwroot folder for security
    reasons.

    A couple questions:
    Where is this code located? If it's in one of the event handler subs in
    global.asa, then the IWAM_machinename account also needs Modify permissions
    for the folder containing the database.
    Is this database file located on the same machine as the website?
    Is your website using Anonymous access? If it's using Integrated
    Authentication with Anonymous disabled, then all database users require
    Modify permissions for the folder containing the database, not just IUSR and
    IWAM.
    Have you modified the isolation settings for your application? With some
    settings, the IWAM account is doing the work, not the IUSR, so you need to
    grant permissions to the IWAM account.

    xg wrote:
    > Thanks everyone. I grant the "Modify" permission of
    > "c:\inetpub\wwwroot\triomotors\" for user "IUSR_DESKTOP" and the code
    > now looks like this:
    >
    > var MM_DBConn=Server.CreateObject("ADODB.Connection");
    > MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=c:\inetpub\wwwroot\triomotors\trio.mdb;");
    > MM_DBConn.Execute(MM_editQuery);
    >
    > I still get the same error message. Please help. Thanks!
    >
    > xg
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> xg wrote:
    >>> Hi, I am writing an ASP page which contains the following code:
    >>>
    >>> var MM_DBConn=Server.CreateObject("ADODB.Connection");
    >>> MM_DBConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data
    >>> Source=c:\trio.mdb;"); // failed on this line
    >>> //MM_editQuery is an INSERT sql statement
    >>> MM_DBConn.Execute(MM_editQuery);
    >>>
    >>> When I run this on a Windows 2000 Professional system, I got the
    >>> following error:
    >>>
    >>> Microsoft JET Database Engine error '80004005'
    >>>
    >>> Not a valid file name.
    >>>

    >>
    >> This is most likely a permissions problem. If your website is using
    >> Anonymous access, then the IUSR_machinename account needs to be
    >> granted Change permissions for the folder containing your database
    >> file (which probably should be located in a subfolder, not in the
    >> root). http://www.aspfaq.com/show.asp?id=2009
    >>
    >> --
    >> Microsoft MVP - ASP/ASP.NET
    >> Please reply to the newsgroup. This email account is my spam trap so
    >> I don't check it very often. If you must reply off-line, then remove
    >> the "NO SPAM"


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Mar 20, 2006
    #6
    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. THY
    Replies:
    4
    Views:
    529
    Gönen EREN
    Aug 22, 2003
  2. =?Utf-8?B?dnZlbms=?=
    Replies:
    10
    Views:
    1,740
    Juan T. Llibre
    Oct 19, 2005
  3. damezumari
    Replies:
    0
    Views:
    586
    damezumari
    Mar 27, 2006
  4. Nicolae Fieraru

    developing asp with Access database open

    Nicolae Fieraru, Mar 29, 2005, in forum: ASP General
    Replies:
    2
    Views:
    190
    Nicolae Fieraru
    Mar 30, 2005
  5. Replies:
    2
    Views:
    167
Loading...

Share This Page