473,508 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connection String: Global.asax vs. web.config file

Upon reading through my ASP.NET book, I've learned how to place the
connection string in both locations in my application. Just due to habit, I
naturally want to place my SQL Server connection string in the asax
file...but are there really advantages to having in one file over the other?

Thanks
Nov 18 '05 #1
2 3067
Your web.config file is generally considered a better place because it's a
simple text file that is easily updated without needing to recompile
anything and changes go into effect immediately.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Upon reading through my ASP.NET book, I've learned how to place the
connection string in both locations in my application. Just due to habit, I naturally want to place my SQL Server connection string in the asax
file...but are there really advantages to having in one file over the other?
Thanks

Nov 18 '05 #2
I agree.

I use the web.config file because in our environment I
have to move an application from development to staging
(for testing) and then up to production. So rather than
making the change in the asax file and recompiling every
time before pushing the application up to the next stage I
just open the web.config and make the change.

I guess it's all just preference, whatever you feel most
comfortable in doing, but I vote for web.config

Jeremy
-----Original Message-----
Your web.config file is generally considered a better place because it's asimple text file that is easily updated without needing to recompileanything and changes go into effect immediately.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able- consulting.com
"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in messagenews:%2****************@TK2MSFTNGP12.phx.gbl...
Upon reading through my ASP.NET book, I've learned how to place the connection string in both locations in my application. Just due to habit,
I
naturally want to place my SQL Server connection string
in the asax file...but are there really advantages to having in one

file over theother?

Thanks

.

Nov 18 '05 #3

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

Similar topics

4
2413
by: Leo Muller | last post by:
I am about to deploy my first ASP.NET project. But, I was used to store my variables, such as connection strings, in the global.asa file, in an application. However, these variables are different...
3
6114
by: hansiman | last post by:
I use Application_Start in global.asax to set some physical folder paths ie.: Application("pdf") = "c:\www\<site>\pdf\" global.asax uses code behind. When I move the project from the dev to...
9
2118
by: Chris | last post by:
where is the best place to put the connection string for use through-out my app? right now I use, in every page/sub/etc: SqlConnect = New SqlConnection("Server=xxxx;uid=xxx;pwd=xxxx;database=xxx")...
8
4845
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
3
1968
by: Peter Afonin | last post by:
Hello, I put the connection string to the Web.config file, then in Global.asax I'm assigning this string to the application variable: cn = New OracleConnection cn.ConnectionString =...
9
4966
by: nbs.tag | last post by:
hey guys heres my question. I was told by a little birdie that .net 2.0 has the ability to read a connection string directly from a registry key. so in the registry key a string value of say :...
37
8908
by: sam44 | last post by:
Hi, At startup the user log on and chooses the name of a client from a dropdownlist, which then changes dynamically the connection string (the name of the client indicates which database to use)....
5
1769
by: djc | last post by:
is it still customary to use web.config and global.asax to store connection strings? For example storing the string in web.config and using application start procedure in global.asax to declare a...
0
3757
by: Alias | last post by:
Hi - I have a site that runs on a development and production server. I'd like to programmatically change the connection string the provider uses in the web.config file and have the provider use...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.