go to ISQsolutions.com | Contact Us

 
Q10106 - INFO: How do I connect to a MS Access database in ASP.NET using DSN-less?

We assume that the MS Access database in located in the /database folder outside of your web root directory, which is recommended for security reasons.

 

<code>

 string databaseName = "YourDatabaseName.mdb"

 string pathDB = Server.MapPath("/") + @"..\database\" + databaseName;

 string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";

 strConnection += @"Data Source=" + pathDB;

 OleDbConnection objConnection;

 objConnection = new OleDbConnection(strConnection);

</code>

 

DSN-less connections are faster and more reliable.

 

These examples may not work for you without certain modifications.

The purpose of the examples is to give you a general idea on the topic.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 2/2/2005 2:14:00 PM.
Last Modified on 9/15/2008 3:36:00 PM.
Last Modified by ISQ Solutions Inc.
Article has been viewed 19800 times.
Rated 6 out of 10 based on 35 votes.
Print Article