none
connecting visual studio 2008 to access 2007 database RRS feed

  • Question

  • 1. I've created a simple access 2007 database (c:\myaccessdb.accdb)

    2. within visual studio (08) click on tools/connect to database

    3. select Microsoft Access Database File & click Continue

    4. what do I put in "ConnectionString"???  web search suggested: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myaccessdb.accdb;Persist Security Info=False;

    5. click "Test Connection" - success (great)

    6. click "OK" to add connection - error message: Format of the initialization string does not conform to specification starting at index 0.

    Any help would be greatly appreciated!!!

    thx
    • Moved by Cindy Meister MVP Tuesday, April 14, 2009 8:22 AM data connection is not part of VSTO
    Tuesday, April 14, 2009 5:29 AM

Answers

  • This error "Format of the initialization string does not conform to specification starting at index 0." is indicative of a faulty connection string.  Just taking a quick glance at the connection string above, it looks like its missing permission information in the connection.  Can you also verify if the escape character (\) included in the string when refering to "c:\myaccessdb".  It can be escaped as the following: "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\myaccessdb.accdb;Persist Security Info=False" or  @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myaccessdb.accdb;Persist Security Info=False";.  This is assuming that the connection string is defined as a variable and not included as part of a config file.

    Wednesday, April 15, 2009 5:03 PM

All replies

  • Hi sid_idris

    You'll find a description of what VSTO is in the forum's Please Read First message. You'll notice that the "Tools" have no support for Access. I'm going to move this message to a forum for ADO.NET, as all data connections for Visual Studio are done using that technology. You may also want to ask in an Access newsgroup; you'll find a link in the Please Read First message I linked to, above.
    Cindy Meister, VSTO/Word MVP
    Tuesday, April 14, 2009 8:21 AM
  • This error "Format of the initialization string does not conform to specification starting at index 0." is indicative of a faulty connection string.  Just taking a quick glance at the connection string above, it looks like its missing permission information in the connection.  Can you also verify if the escape character (\) included in the string when refering to "c:\myaccessdb".  It can be escaped as the following: "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\myaccessdb.accdb;Persist Security Info=False" or  @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myaccessdb.accdb;Persist Security Info=False";.  This is assuming that the connection string is defined as a variable and not included as part of a config file.

    Wednesday, April 15, 2009 5:03 PM
  • It's ok. For connecting to Microsoft Access 2007 database from Visual Studio 2008, just use the coding in C#

    OleDbConnection

    a = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Northwind 2007.accdb;");

    a.Open();

     

    MessageBox.Show("Establised connection with access 2007 database");

     

     

    ---Md. Showkot Ali, MCT, Bangladesh


    Md. Showkot Ali

    Sunday, August 21, 2011 4:15 AM