Access Connection string - complete example

Discussion in 'Databases' started by John Kauffman, May 28, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have found some info in this forum on Access connection strings, but not an example that is complete and my efforts to get the source path have failed.

    ASP.NET 2.0

    If my control panel says my path is:
    e:\web\MyDomainName\htdocs

    If my site has:
    a folder named _databases holding MyAccess.mdb

    What is the exact syntax for the ### below in the Web.config?
    <add name="VoteBankConnectionString2"
    connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=###"
    providerName="System.Data.OleDb" />

    It seems there are two techniques. Can you give me the exact syntax for each?
    server.mappath and ~/

    Thanks.
     
  2. Hi,
    This is the way I did it on a DASP server with Access and ASP.NET 2:

    Dim strConnection As String = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("../_database/mydb.mdb")

    Salute,
    Mark
     
  3. I may be wrong, but I don't think the concatenation will work in the Web.config file.

    Here is a more clear description of he problem:

    ASP.NET 2.0 - Syntax for same Access datasource reference for dev and host machines

    I develop on VWD 2008 Express and deploy to my host. Path of Access mdb file is different on each machine. I now use two web.config file: one on dev PC and another on host. Each works fine, but I’d like a syntax for connection string datasource that will work on both machines.

    Host web.config:
    <add name="MyConn"
    connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;
    DATA Source=e:\web\MyDomainName\_database\MyData.mdb"
    providerName="System.Data.OleDb" />


    Development machine web.config
    <add name="MyConn"
    connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source=C:\Websites\MyDOmainName\_database\MyData.mdb"
    providerName="System.Data.OleDb" />

    Thanks.
     
  4. I don't think you got the path right. You have...

    e:\web\MyDomainName\_database\MyData.mdb


    It should be something like this.

    e:\web\[account name]\htdocs\_database\MyData.mdb
     
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