none
How can we connect MS Access 2007 database(.accdb) with Visual Studio2008(C#.net) 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: Object reference not set to an instance of an object
    Any help would be greatly appreciated!!!
    thx
    • Changed type situ1984 Thursday, July 14, 2011 2:04 PM
    Wednesday, July 13, 2011 12:17 PM

Answers

  • Hello,

    Thank you for posting.

    First of all, it looks OK about your connection string. P.S. Here's the helpful link about all connection strings about Access. http://www.connectionstrings.com/access-2007

    Second, we suggest you try to connect database via coding, not Visual Studio IDE. If it's successful, it looks that Data Provider may be corrupted. We suggest you can try to repair your Visual Studio and try it again.

    Please feel free to let us know how it goes.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 15, 2011 9:26 AM

All replies

  • Hello,

    Thank you for posting.

    First of all, it looks OK about your connection string. P.S. Here's the helpful link about all connection strings about Access. http://www.connectionstrings.com/access-2007

    Second, we suggest you try to connect database via coding, not Visual Studio IDE. If it's successful, it looks that Data Provider may be corrupted. We suggest you can try to repair your Visual Studio and try it again.

    Please feel free to let us know how it goes.

    Best Regards,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 15, 2011 9:26 AM
  • I had the same issue what I did was go to the project settings and created the connection string there.

     

    <connectionstring> is in the type dropdownlist after you got that click the ... to do the same process

     

    I had to do this to create a connection to a flat file had the same error

    Friday, July 15, 2011 5:58 PM