How to use an IIS Virtual Directory in a connection string RRS feed

  • Question

  • User841411575 posted

    I have two NLB servers that have a web application in IIS that needs to share the same ms access database.

    In IIS under the Default website I have a web application named; webapp1
    And under the default website I created a Virtual Directory that contains my access db's.
    This is the physical path; \\domain.com\sites$\direcotry1\db

    The connection strings to the access databases in the common.asp file looks like this;
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/websites/dbs/db/access_db.mdb;Persist Security Info=False;"
    ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/websites/dbs/db/access_db.mdb;Persist Security Info=False;"

    How I can change the "ConnectionString" to use the name to the Virtual Directory?

    I am getting this error:

    This is the error I get:

    Error information:

    Microsoft Access Database Engine (0x80004005)
    Could not find file 'c:\windows\system32\inetsrv\fullPath'. 
    Other possible cause of this problem:
    The database cannot be opened, most likely due to incorrect connection settings or insufficient security set on your database folder or file.

    Private pathToDB
    Private dbName 
    Private fullPath

    Private Sub Class_Initialize()

    pathToDB = Server.MapPath("/dbs/")
    dbName = "\access_db.mdb"

    fullPath = pathToDB & dbName 

    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=fullPath;Persist Security Info=False"
    ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=fullPath;Persist Security Info=False;"

    User = "Admin"
    Password = ""
    Set Converter = New clsConverter
    Converter.DateFormat = Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss")
    Converter.BooleanFormat = Array("true", "false", Empty)
    Set objConnection = Server.CreateObject("ADODB.Connection")
    Database = "MSAccess"
    Set Errors = New clsErrors
    End Sub


    If I do a response.write I get the virtual path.

    Private pathToDB
    Private dbName
    Private fullPath

    dbName = "\access_db.mdb"
    pathToDB = Server.MapPath("/dbs/")
    fullPath = pathToDB & dbName

    response.write("The DB Virtual Path is: " & fullPath)

    The DB Virtual Path is: \\server\directory$\directorya\dbs\access_db.mdb

    Not sure why it keeps looking for the database on the c drive. 

    Tuesday, February 23, 2016 7:19 PM

All replies

  • User753101303 posted


    AFAIK you'll have to use a network share. The virtual path is handled by IIS and the Jet provider driver won't know about that. Not directly related but I would strongly consider moving away from Access db files.

    Tuesday, February 23, 2016 7:34 PM
  • User841411575 posted

    This are old applications and cant move away from the access.

    But will try the network share drive.


    Tuesday, February 23, 2016 8:14 PM