Set up MS Access 2007 connection string in web.config

Discussion in 'Databases' started by Swtrse, Apr 26, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello

    I have a little problem configuration an MS Access 2007 Database in the webconfig.

    On my local machine the Database lies in the App_Code folder.
    The web.config entry looks like and works fine
    -----------
    <connectionStrings>
    <add name="Blabla" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='|DataDirectory|\Blabla.accdb';Persist Security Info=False"/>
    </connectionStrings>
    ----------

    Now I tried to move the Access filte into the _database folder.

    I tried 2 Version but none of them worked
    --------------------
    <connectionStrings>
    <add name="Blabla" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='~\_database\Blabla.accdb';Persist Security Info=False"/>
    </connectionStrings>
    ----------------------
    <connectionStrings>
    <add name="Blabla" providerName="Microsoft.ACE.OLEDB.12.0" connectionString="~/_database/Blabla.accdb"/>
    </connectionStrings>
    ---------------------

    So what do I have to write in the webconfig so that my site is working again.

    BTW the spaces at 12.0 in the providerName are a bug in the forum. There is no space between the dot and the zero.

    Michael
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    what error are you getting?

    what happens if you put in the full path, eg. e:\web\[username]\htdocs\_database\blabla.accdb
     
  3. The error was that the databasefile was not found.

    After put in the full path "e:\web\[username]\htdocs\_database\blabla.accdb" all is working fine.

    Thank you for the helping hand.
     
  4. Very Similar Question for SQLExpress Database...

    Hello,

    I am not sure if I should have started a new post but my question is very similar.(Also/FYI, I am fairly new to ASP, databases and hosting in general.) I have detached and uploaded a local SQL database as instructed here:
    https://support.discountasp.net/KB/a188/sql-2008-management-tools.aspx?KBSearchID=31101. My webconfig file looks like this and works perfectly locally.
    <connectionStrings>
    <add name="OrderDatabaseConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\OrderDatabase.mdf;Integ
    rated Security=True;User Instance=True"
    providerName="System.Data.SqlClient" /> </connectionStrings>

    The following is from my discountasp.net control panel.

    "Data Source=tcp:sql2k802.discountasp.net;Initial Catalog=SQL2008_XXXXXX_orderdb UserID=SQL2008_XXXXXX_orderdb_user;Password=******;"

    Can you let me know specifically what part of the connection string should inserted or updated and with what? Also, I do not see the "full path" that was referenced by Bruce to Swtrse (which seemed to fix the issue).



    Any help for the new guy is greatly appreciated:). BTW, I also get a Server Not Found Error.



    Thanks,

    Frank
     
  5. For SQL servers you will not need to look for a full path. The original thread request for a connection string name for an Access database. This works differently then a SQL database.

    Try using this example of a connection string name.

    <connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=DBServerName;Integrated Security=false;Initial Catalog=DBName;User ID=DBLogin;Password=DBPassword" providerName="System.Data.SqlClient" />
    </connectionStrings>

    Log into your account and under SQL database you will see the corresponding information.

    For DBServerName that is the name of the database server 'sql2k802.discountasp.net'. For database name it should start with 'SQL2008'. With DBlogin, it will start with 'SQL2008' and end with 'user'. The password we will not know. Typically when it is first created the db password will match your account password.
     
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