Re: Database Connection - Development to Production



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
.



Relevant Pages

  • Re: Newbie Simple Quick Question
    ... I am working on an old ASP project and I need to make some changes to ... the project files I have can not be opened with VB 2005 Express ... When the DLL is deployed through the component services, ... I am told to simply edit the connection string ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Code Security
    ... You could build connection string on a fly, but never store user and ... I am developing a windows app that is migrating from ACCESS to SQL ... Can the information be stored in a .dll ...
    (microsoft.public.vb.database.ado)
  • 0113 timeout
    ... This may be a SQL error, but I suspect it's a connection string problem, ... I have an Intranet app at the company I work for. ... allow ASP, which is turned off by default. ...
    (microsoft.public.inetserver.asp.general)
  • Re: 0113 timeout
    ... Original URL: ... > This may be a SQL error, but I suspect it's a connection string problem, ... > allow ASP, which is turned off by default. ... > Dim strDBConnection ...
    (microsoft.public.inetserver.asp.general)
  • Re: custom ASP programming has clashed with Frontpage DRW pages with SQL INSERT and UPDATE
    ... I've never heard of any such thing, and I've used ASP since it was first ... >> Both Jim and I told you that you shouldn' be referencing any DLL in your ... >> It is certainly fine to have both FrontPage DRW pages and your own ... >> automatically-generated Connection String in the global.asa file. ...
    (microsoft.public.frontpage.programming)