HOW TO DEFINE CONNECTION STRING FOR MS ACCESS FILES.

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C#
 441  View(s)
Ratings:
Rate this:
Good day everybody

I am using Microsoft Visual Studio 2012 &  Windows 8.1. I have imported access file to Visual Studio by add Connection.
I want to make a connection to that file and display one of the table in a Web Form.
What should I write in the connection string.
CAN ANYBODY HELP ME AS SOON AS POSSIBLE .
  1. Anupam Mishra

    Post:135

    Points:949
    Re: How to define connection string for MS Access files.

    The best place to store the database is in the App_Data folder. In you placed it there, you can use the DataDrectory Directive, otherwise you need to use the full path. Also, instead of using the "database" keyword in the connection string, it should be "data source" Provider=Microsoft.ACE.OleDb.12.0;Data Source=|DataDirectory|db1.mdb
    Also, when using an mdb file, you might as well use the OleDb 4.0 provider, which is installed on all Windows Servers Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|db1.mdb. Here 'db1.mdb' is your access file.

      Modified On Jan-12-2016 11:13:59 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!