5

I am using the enterprise library logging and exception handling.
Currently I am adding the connection string in the configuration file, and this means that it is static.
My problem is that the user may connect to a different database each time depending on his user name. Is there any way to change the connection string at run time?

Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60

2 Answers2

2

I created a CustomTraceListener

Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60
-3

You can set the Connection string at run time by using ConfiguratiomManager class from System.Configuration namaspace as below;

ConfigurationManager.ConnectionStrings[0].ConnectionString = "Your new Connection string";
robert
  • 33,242
  • 8
  • 53
  • 74