Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Dynamic connection string

0.00/5 (No votes)
9 Aug 2004 1  
Creating dynamic connection string on a remote site.

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here