Home > DeveloperSection > Forums > How to define connection string for MS Access files.
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    January-12-2016 11:07 PM

 C# C#  .NET  Database Connection 
Ratings:


 1 Reply(s)
 240  View(s)
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 .


Anupam Mishra

Total Post:135

Points:949
Posted on    January-12-2016 11:13 PM

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

Don't want to miss updates? Please click the below button!

Follow MindStick