472,805 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Database Connection - Development to Production



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
May 17 '06 #1
5 2059
web.config file.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Matt" <ma******@newsgroups.nospam> wrote in message
news:eR**************@TK2MSFTNGP05.phx.gbl...


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

May 17 '06 #2
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;Pw d=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/For...neral/200605/1
May 17 '06 #3
Hi Matt,

Storing connectionString in dll itself is ok. However, it'll make the
connectionstring hard coded and not possible to modify, if you do not care
about this ,then you can just use this approach.

As for .net framework application, we would suggest store connectionString
in application's config file(app.config or web.confing), this can make the
connectionstring's management very convenient and flexible. Also, .net
framework (especially 2.0) has powerful support on config file's
reading/writing....

#Storing and Retrieving Connection Strings
http://msdn2.microsoft.com/en-us/library/ms254494.aspx

Also, if the connectionString will be used in ASP.NET application, we can
perform encryption on them through DPAPI or RSA key:

#How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA
http://msdn.microsoft.com/library/en...6.asp?frame=tr
ue
Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 18 '06 #4
Thank you very much.

The config files are the way to go for all of my ASP.NET applications. I
agree with that. Unfortunately, all of our applications are still classic
ASP and I will require the connection information to be contained within the
dll at this time. I understand that it will be hard coded. Is using ini
files a method of the past? We have other VB 6 programmers here and they use
ini files to store their connection information.

The dll is a Security Control object that I created. It consists of a few
classes that read data from a database to populate the object properties and
collections.

Soon I will be making a post dedicated to converting classic ASP
applications to ASP.NET applications. I have yet to begin to research this
yet so if anyone has any insight or links to articles you could supply me
with it would be much appreciated. I should start a new post for this topic
though.

Thanks again.

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:Bh****************@TK2MSFTNGXA01.phx.gbl...
Hi Matt,

Storing connectionString in dll itself is ok. However, it'll make the
connectionstring hard coded and not possible to modify, if you do not care
about this ,then you can just use this approach.

As for .net framework application, we would suggest store connectionString
in application's config file(app.config or web.confing), this can make the
connectionstring's management very convenient and flexible. Also, .net
framework (especially 2.0) has powerful support on config file's
reading/writing....

#Storing and Retrieving Connection Strings
http://msdn2.microsoft.com/en-us/library/ms254494.aspx

Also, if the connectionString will be used in ASP.NET application, we can
perform encryption on them through DPAPI or RSA key:

#How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA
http://msdn.microsoft.com/library/en...6.asp?frame=tr
ue
Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 18 '06 #5
Thanks for your response Matt,

As for classic ASP to ASP.NET's migration, the MSDN asp.net developer
center has provided some good articles:

#ASP to ASP.NET Migration Guide
http://msdn.microsoft.com/asp.net/re...g/default.aspx

And the www.asp.net is also a very good place to get many new info about
ASP.NET.

Hope this also helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bill Willyerd | last post by:
I have been looking for some documentation that would support or reject my opinion on Production -vs- Development naming conventions. I believe that each environment should be housed on separate...
6
by: Mike L. | last post by:
Hi, Pls, beware that I'm new to this :) I've developed several web appl, either with ASP or ASP.NET. All using SQL server as the back end. In my development environment, I have a single...
4
by: TC | last post by:
Hello All, I apology for posting to many groups but I wasn't sure which group would be best targeted with my question. I have inherited an ASP.Net application that requires some maintenance &...
10
by: mjf | last post by:
Hello, We made a backup image file for a database on one machine (A), and we restored the database on another machine (B), using the backup image file. Everything went fine. But when we try to...
4
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two...
4
by: Sierra | last post by:
Problem: Database connections are not being reused properly. SP_WHO2 shows upwards of 200 connections being created per page request. Most connections exist for 60 seconds then close without...
8
by: situ | last post by:
Hello all, i have Database1 and database2, is it possible to make database connection to database2 by running stored procedure on database1. Thanks and Regards Situ
3
by: RichardLamont | last post by:
We often have to migrate changes to sql server 2000 databases from development to production. Normally we dump the sql from Enterprise Manager for production and development and do a diff (using...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.