|Written by||Imar Spaanjaars|
|Listened to||Tindersticks - Sweet Release from the album Can Our Love...|
Are you looking to hire an experienced software developer or .NET consultant? Then get in touch with me through my company's web site at devierkoeden.com
Found an interesting article on this site? Got inspired by something you read here? Then consider making a donation with PayPal.
Like this article? Or do you think it sucks? Make yourself heard by casting your vote below.Total number of ratings: 146
When you're working with ASP or ASP.NET applications and a Microsoft Access database, you're likely to run into an error like this:
Alternatively, you may get this error instead:
Both errors basically mean the same: the account that your Web server is running under does not have the necessary permissions to read from or write to the database.
This article will explain the steps you need to perform to fix this problem. First I will explain how you can find out the current account that the Web server is using to connect to the database. In the second part of the article I'll explain how to change the security settings so the Web server can successfully access the database.
This article will explain the steps you need to perform on Windows XP Professional. This OS comes with IIS 5.1. as the Web server. For other versions of Windows, like Windows 2000 or Windows Server 2003, the steps will roughly be the same, although the screens may look a little different and the account you need to configure may be different as well. The article also assumes that the hard disk where your Web site resides is formatted with NTFS. If you're using FAT or FAT32 this article does not apply, because these file systems don't support changing the security settings.
Before you can change the security settings for your database, it's important to find out which account your Web server, IIS, is running under. By default, for a Web site that allows anonymous access and is running "classic ASP", this account is called IUSR_MachineName where MachineName is the name of your computer. However, when you are using a security mechanism in IIS other than Anonymous Access, you manually changed the account that IIS uses or you're running your Web site "Out Of Process", you're likely to encounter another user account. Also note that when you're running ASP.NET, the account is different as well. Refer to the FAQ that is listed below the following table for more info.
The following table lists the possible user accounts that IIS is using in various scenario's:
|The Web site or Virtual Directory / Application is configured for Anonymous Access
|The Web site or Virtual Directory / Application is configured for Anonymous Access, but runs out of process (The Application Protection is set to High in the Home Directory or Virtual Directory tab of your Web application)
|The Web site or Virtual Directory / Application is configured for Basic Authentication or Integrated Windows Authentication
||The account you used to log on to your Web application|
|The Web site or Virtual Directory / Application is configured for Anonymous Access, but you manually changed the account used for anonymous access
||The account you specified|
For a detailed examination of the actual account used by the web server in ASP and ASP.NET check out the FAQ: How Do I Determine the Security Account that IIS Uses to Run My Web Site?
To find out how your system is configured, follow these steps:
If you want to know the account that is used for an ASP.NET application read this FAQ. That article will explain the steps described above for both "classic" ASP as ASP.NET applications.
Now that you know which account is used to access your database, it's time to change the security permissions for this account. To be able to change the permissions, it's important that your system is set up to allow you to make these changes. You'll need to have a Security tab on the Properties dialog for a file or folder. By default, on a Windows XP computer that is not part of a network, this will not be the case, so you'll need to perform the following steps to make this tab visible:
With all the preparation taken care off, it's now time to change the security settings for the folder where your Microsoft Access database is stored. It's important to change the permissions for the folder, and not for just the database file. At run time, the Access driver will create temporary lock files (with an .lck extension) to keep track of who is making changes to the database. Without the right permissions on the folder, these lock files cannot be created and the database access will fail. To change these settings, perform the following 5 steps:
To test out whether the Web server can now successfully access and write to the database, it's best to create a page that performs a very simple INSERT or UPDATE statement. This way, you can focus on the security workings, so you're not bothered by the complexity of your application that may result in other errors.
Dim MyConnection Dim MyConnectionString Dim MySQLStatement
MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Databases\WebSite.mdb;User Id=admin;Password="
MySQLStatement = "INSERT INTO Test (Description) Values('Test')"
Set MyConnection = Server.CreateObject("ADODB.Connection")
MyConnection.Open MyConnectionString MyConnection.Execute(MySQLStatement) MyConnection.Close()
Response.Write("Record inserted successfully")
Set MyConnection = Nothing %>
Wonder where to go next?
You can read existing comments below
or you can post a comment yourself on this article
Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
For more information about the Talk Back feature, check out this news item.
Unfortunately, something went wrong and your message or comments have not been submitted successfully.
There's a fair chance things broke down because you tried to post something that looks like HTML. Things that look like HTML include (X)HTML, obviously, XML, ASP.NET markup and c# generics syntax as all of them use the < and > characters.
If that's the case, try altering your message and remove anything that looks like an angled bracket. You can replace them with [ and ] for example so you can still make it look like HTML to some extend.
If, on the other hand, you were trying to spam this web site, I am pretty glad I caught you in the act and stopped you from doing so ;-)
The number you entered is not correct. Please enter the sum of the two numbers again.