C#
I am trying to store my connection settings in a config file, mainly so I
can easily change the db that the app connects to without doing a release of
code. I have the config file sorted fine, and I can read the connection
string in and connect. But at the moment everytime a connection is made to
the database to get records, update records insert records etc etc, this file
has to be read back in again. Is this an ok way of doing it, or is there a
better method? Maybe retrieving the string once at login, and somehow
storing it in a global parameter of some kind?? Would storing it in the
reigstry be any better? Is there a performance hit with this, or should I
just settle for this constant disk read?
Thanks
Ste 4 2681
You could store your connection as an application veriable that is only read
from the config file once.
web config...
<appSettings>
<add key="myConString" value="Persist Security Info=False;Network=dbmssocn;
User ID=myUser;Password=myPassword;Initial Catalog=myDatabase;Data
Source=myserver" />
</appSettings>
ASPX...
Session["ConnectionString"] =
ConfigurationSettings.AppSettings.Get("myConString ")
--
JP
..NET Software Develper
"Steve" wrote: C#
I am trying to store my connection settings in a config file, mainly so I can easily change the db that the app connects to without doing a release of code. I have the config file sorted fine, and I can read the connection string in and connect. But at the moment everytime a connection is made to the database to get records, update records insert records etc etc, this file has to be read back in again. Is this an ok way of doing it, or is there a better method? Maybe retrieving the string once at login, and somehow storing it in a global parameter of some kind?? Would storing it in the reigstry be any better? Is there a performance hit with this, or should I just settle for this constant disk read?
Thanks
Ste
Oh forgot:
need to add:
using Ststem.Configuration;
--
JP
..NET Software Develper
"Steve" wrote: C#
I am trying to store my connection settings in a config file, mainly so I can easily change the db that the app connects to without doing a release of code. I have the config file sorted fine, and I can read the connection string in and connect. But at the moment everytime a connection is made to the database to get records, update records insert records etc etc, this file has to be read back in again. Is this an ok way of doing it, or is there a better method? Maybe retrieving the string once at login, and somehow storing it in a global parameter of some kind?? Would storing it in the reigstry be any better? Is there a performance hit with this, or should I just settle for this constant disk read?
Thanks
Ste
How do i implement this kind of thing into a windows app?
Thanks
"JP" wrote: You could store your connection as an application veriable that is only read from the config file once.
web config...
<appSettings> <add key="myConString" value="Persist Security Info=False;Network=dbmssocn; User ID=myUser;Password=myPassword;Initial Catalog=myDatabase;Data Source=myserver" /> </appSettings>
ASPX... Session["ConnectionString"] = ConfigurationSettings.AppSettings.Get("myConString ") -- JP .NET Software Develper
"Steve" wrote:
C#
I am trying to store my connection settings in a config file, mainly so I can easily change the db that the app connects to without doing a release of code. I have the config file sorted fine, and I can read the connection string in and connect. But at the moment everytime a connection is made to the database to get records, update records insert records etc etc, this file has to be read back in again. Is this an ok way of doing it, or is there a better method? Maybe retrieving the string once at login, and somehow storing it in a global parameter of some kind?? Would storing it in the reigstry be any better? Is there a performance hit with this, or should I just settle for this constant disk read?
Thanks
Ste
Hope this helps: http://msdn2.microsoft.com/en-us/library/ms134260
This explain how to access the configuration manger via a client app. Sorry,
so used to web apps didnt think to ask.
--
JP
..NET Software Develper
"Steve" wrote: How do i implement this kind of thing into a windows app?
Thanks
"JP" wrote:
You could store your connection as an application veriable that is only read from the config file once.
web config...
<appSettings> <add key="myConString" value="Persist Security Info=False;Network=dbmssocn; User ID=myUser;Password=myPassword;Initial Catalog=myDatabase;Data Source=myserver" /> </appSettings>
ASPX... Session["ConnectionString"] = ConfigurationSettings.AppSettings.Get("myConString ") -- JP .NET Software Develper
"Steve" wrote:
C#
I am trying to store my connection settings in a config file, mainly so I can easily change the db that the app connects to without doing a release of code. I have the config file sorted fine, and I can read the connection string in and connect. But at the moment everytime a connection is made to the database to get records, update records insert records etc etc, this file has to be read back in again. Is this an ok way of doing it, or is there a better method? Maybe retrieving the string once at login, and somehow storing it in a global parameter of some kind?? Would storing it in the reigstry be any better? Is there a performance hit with this, or should I just settle for this constant disk read?
Thanks
Ste
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Dunaway |
last post by:
I have a web service that references a data class library which performs
SQL Server access. Since the web service is also a class library, there is
no App.Config, only Web.config. Is Web.Config...
|
by: Guadala Harry |
last post by:
What are my options for *securely* storing/retrieving the ID and password
used by an ASP.NET application for accessing a SQL Server (using SQL Server
authentication)? Please note that this ID and...
|
by: Steve |
last post by:
C#
I am trying to store my connection settings in a config file, mainly so I
can easily change the db that the app connects to without doing a release of
code. I have the config file sorted...
|
by: amber |
last post by:
Hello,
I've just upgraded from .NET 2003 to 2005 and to SQL Server Express 2005.
I've rebuilt my connection string. Before I used app.config, and now have
the connection string is in the...
|
by: Paul Cheetham |
last post by:
Hi,
I am developing an application that needs to store some machine-specific
settings. The application is going to be published on the network in
order to keep the clients on the latest version....
|
by: Ted |
last post by:
In WSAT, I get the following error when trying to set up my provider:
Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site...
|
by: Rob |
last post by:
The app.config in VB 2005 appears to be riddled with bugs....
From solution explorer I right click on the Project | Properties... then I
use the grid to add the app settings... AND they are saved...
|
by: Man T |
last post by:
I just wonder what is/are your practices to build the SQL Server connection
string?
Use object to build the connection string from config file or somewhere?
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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...
| |