简体   繁体   中英

Azure Websites Classic ASP Connection String to Access Database

I am migrating all my websites to Azure Website. One of the sites is a Classic ASP site with a Access database back end (mdb file). The customer does not want to pay to upgrade the site to MYSQL or Azure SQL Server. In the code is a Microsoft.Jet.OLEDB.4.0 connection string with a datasource pointing to a the physical path of the mdb file.

I can not find any path information in the website configuration to use to set the datasource of the connection string.

Is this possible and if so what should be done to get this to work?

The environment variable %HOME% points to your home directory. It expands to D:\\home your wwwroot is under %HOME%\\site\\wwwroot you can build your path from there.

You could use server.mappath in your conn string to set a relative path. Eg if your database is in a folder called private at the same level as your root directory you could use

conn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.Mappath("../private/yourmdbfile.mdb") 

You can also use

Response.Write Server.Mappath("nameofthisfile.asp")

to display the physical path of the file you're viewing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM