Introduction
Well, often I hear the problem of creating a connection sting on a remote site, because people don't have physical path to the location of their site database or any other thing for that method.
Over here, I will show how to create a connection string. This tutorial is for beginners and intermediate web developers, and the advance developer will know this already.
First, always use relative paths to make a site, and the paths to the database used in your website should also be relative. There is a built-in function in ASP and also in ASP.NET since it's a server method.
server.mappath("relative path")
method is used to create physical path for the required file.
For example, I have a file called sitedata.mdb which is in a folder site_assert, and I am creating a path in a page which is in the parent folder. Then, this should be done:
strconn = server.mappath("site_assert/sitedata.mdb")
This assigns the physical path to the variable strconn
, which you can further use.