Setting a database path in realworld ASP .net app

cpopham

Junior Contributor
Joined
Feb 18, 2004
Messages
273
I have a nice little Access 2000 database. I am currently using it on my local machine with my ASP .net app. It works great on my local machine, but I am getting ready to upload the database and ASP app to a regular web server. My problem is that on my local machine I set the Data Path to C:\MyProject\Databases\schedule.mdb. Now I have tried ...Path=\Databases\schedule.mdb, but No matter what I try, it will not work unless I have my path start at the root of C:. What do I need to change and how do I need to change it to get this to work on the webserver after upload??? I thought maybe server.mappath, but that says that I have to have a virtual driectory or something, so anyone have any ideas?

Thanks,
Chester
 
Will you be using a web host server or will it be a IIS server you have set up?
 
Ooh! Ooh! I know this one! *raises his hand*

Request.PhysicalApplicationPath

(I think that Server.MapPath("") would work, also)

:)
 
It will be on a web host server. So how do I set up the Request.PhysicalApplicationPath

?

And thanks for the help! :)

Chester
 
You don't do anything to set it up; it's a property. Just make sure that all your
physical paths you use (to find the database file and such) contain this property (or
some form of it).
 
The path where the database is located is:
myProject\Database\NWind.mdb

I am going to upload the Database\NWind.mdb folder to the Web Server and the aspx file will be under the myProject folder.

So would it be:
Data Source=Request.PhysicalApplicationPath = "database\Nwind.mdb"

?

Chester
 
You're close; use + (or & in VB) to concatenate the strings:

Data Source=Request.PhysicalApplicationPath &"database\Nwind.mdb"
 
Thank you for the help... Coding Windows apps with VB .NET is easier than coding ASP .NET web Apps. A lot more things to consider :)

Chester
 
Yes, it is a different way of thinking, but not nearly as difficult as classic ASP (in terms
of transitioning). VBScript... ick
 
Make sure to check with your web host to determine if they have any restrictions. I use a web host that requires all database files to be placed in a specific folder that they set up for you like "_database". If I try to use some other path the web form will not function correctly.
 
Good point Tate, there are some that even place the Database folder outside your root application directory. Usually at the same level. In that case they will give you the physical path of the location.
 
Back
Top