Connecting to a Microsoft Access database with ASP.NET
(Page 1 of 6 )
In this article, I shall discuss different methodologies for connecting to a Microsoft Access database using ASP.NET without any errors.
A downloadable file for this program is available
here.
Every .NET programmer knows how to connect to Microsoft SQL Server 2000/2005 using ASP.NET very easily. Connecting to (and working with) a Microsoft Access database is not as simple as MS SQL Server. It is always possible to run into errors when working with Microsoft Access together with ASP.NET.
It all starts with security. MS SQL Server has its own security policies, and it is a concrete RDBMS when compared to MS Access. Connecting to a Microsoft Access 2003 database is very easy, but when you try to manipulate some data within the database, your application may run into simple errors. I try to address the most important issues in this article.
In this article, I shall demonstrate how to connect and work with a Microsoft Access 2003 database in a very easy manner, with several possibilities. For the sake of this demonstration, I simply created a database using Microsoft Access 2003 with only one table, “emp,” having fields “empno,” “ename,” “sal” and “deptno.” I added a few rows to the same table and saved the database with the file name “MyDB.mdb” in the path “c:\AccessDB”.
As you can see, I didn’t save the MS Access DB file in any virtual directory (like “c:\inetpub\wwwroot”) where my ASP.NET application generally lives! It is strongly recommended to have the database stay outside any virtual directory (due to several security considerations).
I enclosed the source code in the form of a single file (“.zip” file). You need to extract the folders from the zip and configure virtual directories on your own. I developed these applications using Microsoft Windows Server 2003 Standard Edition with Microsoft Visual Studio.NET 2003 Enterprise Architect and Microsoft Access 2003.
Next: Connecting to a Microsoft Access database directly using ASP.NET >>
More Microsoft Access Articles
More By Jagadish Chaterjee