473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Dynamic Connectionstring in Web.Config ?

Setting dynamic connectionstring in aspx files is easy, for example :

"server=(localhost);uid=sa;pwd=; databse=" + database

But can i do this in Web.Config? I want to pass the value of the
variable "database" from aspx to Web.Config ad then set the dynamic
connectionstring there. Can i do that ? thanks a lot
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 19 '05 #1
2 2799
One of the features of this tool can dynamically set/update the Web.Config's
Key-Value on-fly:
www.aspsimply.com/vbnet/ProTool.aspx

Regards,

"summer00" <ka******@yahoo-dot-com.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
Setting dynamic connectionstring in aspx files is easy, for example :

"server=(localhost);uid=sa;pwd=; databse=" + database

But can i do this in Web.Config? I want to pass the value of the
variable "database" from aspx to Web.Config ad then set the dynamic
connectionstring there. Can i do that ? thanks a lot
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 19 '05 #2
Make the connect string as:

"server=(localhost); uid=sa; pwd=; database = {0}"

In Application_Load method (in global.asax) or whenever you get the
database name, create an application-scope (or whatever suits you)
variable by formatting the string. Example:

void SomeMethod(string databaseName)
{
string connstr = ConfigurationSettings["connectionString"];
connstr = String.Format(connstr, databaseName);

// now you can scope this connstr to your likes.
}

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #3

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

Similar topics

0
by: Ronald Colijn via .NET 247 | last post by:
Hello all you people, Thanks for reading this. I hve a strange thing which annoys me noend. I am using VS.NET with MS-Access DB, framework version 1.1,Windows XP Pro, IIS 5.1. In my webforms I...
5
by: Mike | last post by:
I am writing a .NET application in C# that uses Crystal Reports. I want the crystal reports to grab information from a database no matter where the database is located. To do this, I want to...
7
by: jdn | last post by:
I have a class called myConfigurationClass with 3 private members, and 3 public gets (so, 3 read-only properties). So, for instance private members: _A, _B, _ public gets A, B, Oh, and they...
5
by: WFB | last post by:
Hi, I have an application with a couple of referenced assemblies. The referenced assemblies and my application all share a few configuration settings with the same name but different values. ...
3
by: GaryB | last post by:
In a large asp.net project we have always kept our connection string in the Web.config as so.... <appSettings> <!-- User application and configured property settings go here.--> <!-- Example:...
3
by: Christopher Kimbell | last post by:
I have a class library that contains a number of TableAdapters and I'm using this from a web application. Is there a way of getting the TableAdapters to use the connectionstrings defined in...
3
by: Nuno | last post by:
At first, I was trying to encrypt ConnectionStrings in my app.config and still be able to modify my datasets. So, i had to modify the Settings.Designer.cs file to handle the decryption aspect in...
2
by: Sagaert Johan | last post by:
Hi The Dataset wizard in VS2005 generates a setting entry for the connectionstring. The connectionstring is in the settings file. Setting the property to a dynamic value by writing to the...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
tracyyun
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...
0
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,...

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.