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;databa se=xxx")
for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx! 9 2110
web.config is the best place:
<appSettings>
<add key="connectionString" value="1" />
</appSettings>
under the <configuration> root element. You can then access it via
System.Configuration.ConfigurationSettings.AppSett ings("connectionString")
in vb.Net and with [ ] in c#
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com... 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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
The configuration file is the best choice.
"Chris" wrote: 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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
The last project I worked on we held the value in web.config but used the
Application_Start event to populate a global variable.
Was this "worth" it? Or should we have just stuck with GetConfiguration
calls each time?
My thinking was get the valule in memory and save the file read each time...
What do you guys think? al*****@yahoo.com
"Chris" wrote: 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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
In my projects I use an utility class like that :
public sealed class Settings
{
private static string connectionString = "";
public static string ConnectionString
{
get { return connectionString; }
}
static Settings ()
{
ConnectionString = ...AppSettings["connectionString"];
}
}
"alaspin" wrote: The last project I worked on we held the value in web.config but used the Application_Start event to populate a global variable.
Was this "worth" it? Or should we have just stuck with GetConfiguration calls each time?
My thinking was get the valule in memory and save the file read each time...
What do you guys think?
al*****@yahoo.com
"Chris" wrote:
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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
i agree with vko, depending on what you mean by "global variable" was it
just a static field (good) or using the Application object (bad) ?
Also, not that the web.config is cached internally...so perf won't change
much..more about usability...and I think vko's example provides the greatest
abstraction.
For the record, I only ever use custom configurations, so that's how I do
it: http://openmymind.net/Configuration/index.html
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Vko" <Vk*@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com... In my projects I use an utility class like that :
public sealed class Settings { private static string connectionString = "";
public static string ConnectionString { get { return connectionString; } }
static Settings () { ConnectionString = ...AppSettings["connectionString"]; }
}
"alaspin" wrote:
The last project I worked on we held the value in web.config but used
the Application_Start event to populate a global variable.
Was this "worth" it? Or should we have just stuck with GetConfiguration calls each time?
My thinking was get the valule in memory and save the file read each
time... What do you guys think?
al*****@yahoo.com
"Chris" wrote:
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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this
app. maybe in the Global.asax or webconfig file???
thanx!
Yes, we lobbed it into the Application object (old ASP habit)
Good point about the cacheing - thnaks guys al*****@yahoo.com
"Karl Seguin" wrote: i agree with vko, depending on what you mean by "global variable" was it just a static field (good) or using the Application object (bad) ?
Also, not that the web.config is cached internally...so perf won't change much..more about usability...and I think vko's example provides the greatest abstraction.
For the record, I only ever use custom configurations, so that's how I do it: http://openmymind.net/Configuration/index.html
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Vko" <Vk*@discussions.microsoft.com> wrote in message news:68**********************************@microsof t.com... In my projects I use an utility class like that :
public sealed class Settings { private static string connectionString = "";
public static string ConnectionString { get { return connectionString; } }
static Settings () { ConnectionString = ...AppSettings["connectionString"]; }
}
"alaspin" wrote:
The last project I worked on we held the value in web.config but used the Application_Start event to populate a global variable.
Was this "worth" it? Or should we have just stuck with GetConfiguration calls each time?
My thinking was get the valule in memory and save the file read each time... What do you guys think?
al*****@yahoo.com
"Chris" wrote:
> 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;databa se=xxx") > for sql server 2k connection > > This connection is for all users,and is the only connection for this app. > > maybe in the Global.asax or webconfig file??? > > thanx!
When you store it in web.config, it *is*
in memory after the application starts.
web.config is loaded into memory
as soon Application_OnStart initializes.
Juan T. Llibre
ASP.NET MVP
===========
"alaspin" <al*****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com... The last project I worked on we held the value in web.config but used the Application_Start event to populate a global variable.
Was this "worth" it? Or should we have just stuck with GetConfiguration calls each time?
My thinking was get the valule in memory and save the file read each time...
What do you guys think?
al*****@yahoo.com
"Chris" wrote:
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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
thanx guys, this did the trick. I also added this to my custom dll that I add
to my project to control login. Works like a charm.
"Karl Seguin" wrote: web.config is the best place:
<appSettings> <add key="connectionString" value="1" /> </appSettings>
under the <configuration> root element. You can then access it via System.Configuration.ConfigurationSettings.AppSett ings("connectionString") in vb.Net and with [ ] in c#
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Chris" <Ch***@discussions.microsoft.com> wrote in message news:D2**********************************@microsof t.com... 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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx!
Check out this faq, http://www.extremeexperts.com/Net/FA...ionString.aspx
--
-Saravana http://dotnetjunkies.com/WebLog/saravana/ www.ExtremeExperts.com
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:D2**********************************@microsof t.com... 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;databa se=xxx") for sql server 2k connection
This connection is for all users,and is the only connection for this app.
maybe in the Global.asax or webconfig file???
thanx! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: iKiLL |
last post by:
Hi All
Code Below for this problem
ERROR: "An existing connection was forcibly closed by the remote host"
|
by: Cintury |
last post by:
Hi all,
I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
|
by: ninjamonkey |
last post by:
Hi all,
I've developed a mobile application for windows mobile 5.0 that has
been in use for a while (1 year and a couple of months). It was
developed in visual studios 2005 with a back-end sql...
|
by: Robert Avery |
last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and
displayed for the user all connection events, so that I could easily
see what SQL was taking a long time, and when it freezes, I...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
| |