Connection String change at runtime
Posted: Mon 18 Oct 2010 16:50
I need to dynamically generate my connection string at runtime since the database that is used is dependent on who is logged into the system. I would like to generate the connection string in its own class... however I have not been able to get any of the Devart design tools to work unless they reference a connection string in web.config or system settings. Is there a way to get the design tools to work and reference a connection string returned in a class/method?
For example I can manually change the generated code to the following.... this works for my executed code but nothing works in Visual Studio at design time (making development more challenging):
Dim conString As clsConnectionString = New clsConnectionString
Me.MySqlConnection1.ConnectionString = conString.GetConnectString(HttpContext.Current.Session("domain"))
Me.MySqlConnection1.Name = "MySqlConnection1"
Me.MySqlConnection1.Owner = Me
Maybe someone has suggestions on another way to do this? Or how to make this work?
For example I can manually change the generated code to the following.... this works for my executed code but nothing works in Visual Studio at design time (making development more challenging):
Dim conString As clsConnectionString = New clsConnectionString
Me.MySqlConnection1.ConnectionString = conString.GetConnectString(HttpContext.Current.Session("domain"))
Me.MySqlConnection1.Name = "MySqlConnection1"
Me.MySqlConnection1.Owner = Me
Maybe someone has suggestions on another way to do this? Or how to make this work?