Re: Database Connection - Development to Production
- From: "smc750 via DotNetMonster.com" <u21663@uwe>
- Date: Wed, 17 May 2006 15:29:51 GMT
There many ways to store connection strings. Unfortunately, they all involve
more code. In the days of ASP, we would store multiple connection strings in
the com dll one for production, testing and development. Then we would
require an extra parameter in our query strings when navigating to the asp
page. For instance, myapplication.asp?db=D where D meant development. Each
asp page would store this variable and send it as parameter to the data
access layer so it knew which connection string to use. I don't recommend
storing connection strings in the code. If your network administrator
migrates the database to another server then you will have to do another code
deployment.
Other ways, may be to store the connection string in the registry, web config
file or even a centrally accessible database. All these methods can use
encryption and removes the dependency of the connection string on the
assembly. To prevent having to change the connection string based on the
environment you can store all the connection strings and like I stated above
somehow detect what environment you are on and use the appropriate connection
string.
smc750
http://www.certdev.com
Matt wrote:
Hello,
What is the best way to handle the database connection string for a class
library project that will be compiled and used as a .dll? This .dll will be
accessed via classic ASP and in the future by ASP.NET pages. I have created
a constant that contains the connection string (as shown below).
Private Const sConnStr As String =
"Server=ServerA;Database=Intranet;Uid=username;Pwd=password"
This connection string is for the development server. When I deploy to the
production server I don't want to change the connection string to the
Production server's credentials. I am new to creating a.dll so please bear
with me here. I am a web programmer. In my classic ASP I utilize Server_Name
scripts to set the proper connection string based on the server the
application is running on. Is there a similar method to accomplish this
within a .dll? I know from my ASP.NET pages I could use the web.config file
but I can't do that from classic ASP pages. I want to maintain the
connection string within the dll itself. Any detailed examples or a link in
the right direction would be much appreciated.
Thanks in advance,
Matt
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-general/200605/1
.
- Follow-Ups:
- Re: Database Connection - Development to Production
- From: Steven Cheng[MSFT]
- Re: Database Connection - Development to Production
- References:
- Prev by Date: Re: Data Warehousing
- Next by Date: Re: Data Warehousing
- Previous by thread: Re: Database Connection - Development to Production
- Next by thread: Re: Database Connection - Development to Production
- Index(es):
Relevant Pages
|