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 2679
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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: 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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |