Using ADO.NET on a remote server

PARANOiA

Veteran
Hey, got an issue relating to a site I'm building. It was actually part of a uni assignment - web application - but my other half loved it, so I've bought a domain and have a host.

I have a slight issue when transferring my app, which works from home, to the remote server, however. At the moment I've got my site in the inetpub\wwwroot folder, and the backend Access database in a folder called inetpub\database. It's easy to connect from home, as I can set the data source property to the local file name (eg "c:\inetpub\database\blah.mdb").

How can I achieve this with my remote server? I don't want to host the database in the same folder as the web app for security reasons, of course. Is there a solution?
 
Use the Server.MapPath() method to convert a virtual path to a physical one. eg.

Code:
PhysicalPath = Server.MapPath("/database/blah.mdb")

Now the PhysicalPath string will contain the full physical path to blah.mdb on the server. This will work on your home machine and on any server, so long as you keep the database in the same directory relative to the app root.
 
Back
Top