Using a Microsoft Access database with RM Plesk web hosting
Published Date : 11 Mar 2008
Last Updated : 04 Oct 2024
Content Ref: TEC1088412
Operating System
(none)
Part No
(none)
Summary
Configuring a RM Plesk account to communicate with an Access database.
Requirements
Access databases are only supported on those of our Microsoft® Windows® hosting packages which use the Plesk control panel. Our Linux web hosting and non-Plesk Windows web hosting packages do not support them.
Procedure
Uploading your database
Log on to the Plesk control panel and go to File Manager. Note: Most website files are uploaded into the 'httpdocs' folder so that visitors to your website can access them. However, you do not want your database to be accessed directly by your visitors. Instead your web pages need to access it through scripting languages such as ASP. Therefore, you should upload your database file into the 'private' folder.
Open the 'private' folder and click Upload Files.
Click the Browse button and find your database (.mdb) file in the dialog which appears.
Click the green OK button to upload it.
Setting up a database connection
Return to the Home screen and open ODBC Data Sources.
Click the Add New ODBC DSN button.
On the screen which appears, enter a name (letters and numbers only, no spaces) for the connection to your newly uploaded database and (if you wish) a description.
From the drop-down menu, select Microsoft Access Driver (*.mdb) and click the OK button.
The only required field on the next page is Database File Path. This takes the following format: D:\inetpub\vhosts\<yourdomain.com>\private\<yourdatabasename.mdb> Therefore, if your domain is kesborough.sch.uk and your database is called website.mdb, the database file path should be: D:\inetpub\vhosts\kesborough.sch.uk\private\website.mdb. Note: The domain part of the address does not include the www.
You can normally ignore the remainder of the inputs.
Finally, click the Test button to ensure that the connection has been set up correctly. You should see a Connection Successful message. If you do not see this message, there are several things to check:
Have you set the correct database file path? If your domain is www.school.sch.uk the path will not normally include the www.
Is your database password protected? If so, you may need to enter the appropriate username and password.
More Information
Database folder
We recommend that you put your database in the 'private' folder so that users to your website cannot download the MDB file. You can also put it in 'httpdocs' or a subfolder of 'httpdocs'. Note: If you do this, users will be able to download your MDB file.
Accessing your database via ASP
Now that you have created a DSN, you can use it to communicate with your database via an ASP or ASP.NET script (folder permissions will need setting first). In ASP, you can use code similar to the following:
Set adoCon = Server.CreateObject("ADODB.Connection") adoCon.Open "DSN=<DSNName>;"
Replace <DSNName> with the connection name you entered above. You can now use your 'adoCon' object to communicate with your database.
Database path
All RM Plesk web servers are set up in the same way, so the database file path given above should work correctly. However, if you wish to confirm your file path you can do so as follows.
Create a text file with the following content and name it path.asp: <html> <head></head> <body> <p>Path is: <% Response.Write Server.MapPath(Request.ServerVariables("PATH_INFO")) %> </p> </body> </html>
Upload this file to the 'httpdocs' folder on your web space.
Browse to this page via your web browser.
You should see a file path something like the following: D:\inetpub\vhosts\yourdomain.com\httpdocs\path.asp
To obtain the path to your database, simply take off the "httpdocs\path.asp" at the end and add "private\<your database file.mdb>", where <your database file.mdb> is the name of your Access MDB file.
Finally, you should delete 'path.asp' from your site as you do not want casual visitors to your site to be able to see the file path information.
If this article has not helped provide a solution then it is also possible to
log a call...