You can do this without a class which every one seems to "demand." I am
not advocating using global variables, but it is rather easy. It leads
to poor coding practices. However, there are times to be pragmatic.
Add a GLOBAL.ASA file to your project.
In the section Session_Start
protected void Session_Start(Object sender, EventArgs e)
{
Session["ConnectionDB"] = "data source=MYSQLServer;initial
catalog=MyDataBase;integrated security=false;User
iD=whatever;Pwd=whatever;persist security info=True;packet size=4096";
}
This creates a session variable that you can access later on any form
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
connectionDB.ConnectionString =
(string)Session["connectionDB"];
...ect...
I use this technique often when I have a SQL server at a customer site
that has different name and connection string requirement then my home
development environment. This way I put 2 connection strings in the
Global ASA file and then comment one out when at home and comment out
the other when I am at the office.
William
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!