0
votes

I am trying to connect a MS Access database from classic ASP script.

I am using 64bit Windows 7 OS running IIS7

I have following piece of code:

Dim Connection
Set Connection = Server.CreateObject("ADODB.Connection")
Response.Write("object created...")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("D://Somnath//ExtraLogistics//Source//ZipDB.mdb") & ";" 
Response.Write("connected...")

but I am getting this error The website cannot display the page in browser while running application on IIS.

Please help me to connect to the Access database from my IIS.

4
Did you check the server logs?Darin Dimitrov
Does your access path have permissions to be be accessed by your IIS services?George Johnston
if you remove the connections does the response.writes work?Robert

4 Answers

1
votes

Your MapPath does not look correct.

Have a look at this ASP reference.

EDIT:

Server.MapPath points to the Physical location of a virtual reference:

For Example:
'Physical path of the root directory
Response.Write Server.MapPath("/")

'Physical path of DataDirectory
Response.Write Server.MapPath("/DataDirectory/")

Place the ZipDB.mdb in the root of your website and change the Server.MapPath("/")

1
votes

Use a "file dsn":

conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=c:\filepath\yourdb.mdb;"
0
votes

Server.MapPath converts a URL path to the physical path on the server so Server.MapPath("D://Somnath//ExtraLogistics//Source//ZipDB.mdb") is almost certainly wrong.

If the mdb file is located at http://yourhost/Somnath/ExtraLogistics/Source/ZibDB.mdb then you would use Server.MapPath("/Somnath/ExtraLogistics/Source/ZibDB.mdb") and Server.MapPath would give you the location of the mdb file in the server's filesystem.

If the file is located at D:\Somnath\ExtraLogistics\Source\ZipDB.mdb then just use that filepath and remove Server.MapPath completely.

Like so: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Somnath\ExtraLogistics\Source\ZipDB.mdb;"

0
votes

Please note that you want to store your database in a parent directory relative to the location where you execute the asp files. If you don't the database is available through a url in the browser.

Also note that to make this work, 'Allow Parent Paths' must be enabled in IIS.