MS Access connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghulvarma
    New Member
    • Oct 2007
    • 90

    MS Access connection

    I am not able to find "Data Source" when i give the connection for a MS Access plz tell me where I went wrong in thee below shown code snippet

    OleDbConnection connection = new OleDbConnection ();
    connection = new OleDbConnection ("provider=Micr osoft.Jet.OLEDB .4.0",Data Source ="C:\\Docume nts and Settings\\Admin istrator\\My Documents\\Data base1.accdb;");

    As I have used MS Access 2007 the extension is .accdb then here what has to be done?
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Originally posted by raghulvarma
    I am not able to find "Data Source" when i give the connection for a MS Access plz tell me where I went wrong in thee below shown code snippet

    OleDbConnection connection = new OleDbConnection ();
    connection = new OleDbConnection ("provider=Micr osoft.Jet.OLEDB .4.0",Data Source ="C:\\Docume nts and Settings\\Admin istrator\\My Documents\\Data base1.accdb;");

    As I have used MS Access 2007 the extension is .accdb then here what has to be done?
    You can't use Jet for Access 2007, AFAIK. You need to use ACE. Unless you want to save your DB in 2003 format (mdb).

    Look here for the correct connection strings. ConnectionStrin gs.Com has always been a great resource for me.

    Edit:
    Also, if this is an ASP.NET web app, you might want to look into using the DataDirectory functionality. If you put your DB in the App_Data directory, you don't need the full physical path, just one relative to the application. It's at the bottom of the first link I gave you.

    Comment

    Working...