Making Connection to Database

Discussion in 'Classic ASP' started by jonesd923, Apr 19, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. This is my initial attempt to connect to an access database. I have no problems connecting from my localhost machine(see Rem out code), but when I put upload it to the site I get the error below.

    Microsoft JET Database Engine error '80004005'

    Not a valid file name.

    /DatabaseConnect.asp, line 5 <%
    Dim objConn, objRS, strSQL, ADO
    Set objConn = Server.CreateObject("ADODB.Connection")
    'objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\InetPub\wwwroot\EmpPositions\PositionDB.mdb;"
    objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=http://www.mydomain.net/PositonDB.mdb;"
    %> I am not quite sure what I am suppose to do from the web site side. What should line 5 say (objConn.Open "?????")
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Change the line to

    objConn.Open 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=' & server.mappath('\PositonDB.mdb')

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. try this :

    objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &amp; Server.MapPath("/EmpPositions/PositionDB.mdb")

    (the server.mappath command maps the virtual folder to the correct physical path on the server.. this way it works both on your local server AND on the discountasp server)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page