locked
Access Database Connection Problem RRS feed

  • Question

  • User337313793 posted

    Hello,

    I'm having a problem connecting to my database in the server:

    This is my current connection:

    OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=~/Appointments.mdb");

    But I'm getting this error:

    'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\Appointments.mdb' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

    How can i fix this?

    Tuesday, May 27, 2008 2:23 PM

Answers

  • User-158764254 posted

    If your database is in the App_Data folder then this connection string is in the format you want:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\myAccess2007file.accdb;Persist Security Info=False;

     

    If your database is not in the App_Data directory, then you have a security risk and should consider moving it there.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 27, 2008 2:40 PM

All replies

  • User-158764254 posted

    to protect your database, you can move it to the App_Data folder. 

    Then you can check here for the DataDirectory connection string syntax

    http://www.connectionstrings.com/?carrier=access2007

     

    Tuesday, May 27, 2008 2:26 PM
  • User337313793 posted

    Hey,

    Thanks for your response. Yes, I had my connection as the one it was in the article you shared with me. However, when i uploaded my Web app to my web server, it gives me the error I mentioned in the last post. And it makes sense, my web servr does not have a C: drive and I would like to create something where my application looks inside the root folder without specifying a speficic path ... for example ~/ database name ... but it does not work either ... any ideas?

    Thanks,

    Tuesday, May 27, 2008 2:35 PM
  • User-158764254 posted

    If your database is in the App_Data folder then this connection string is in the format you want:

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\myAccess2007file.accdb;Persist Security Info=False;

     

    If your database is not in the App_Data directory, then you have a security risk and should consider moving it there.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 27, 2008 2:40 PM