"Morten Wennevik [C# MVP]" wrote:
Hi Luigi,
I haven't tested this, but if you create an SqlConnection it has a Database
property that might hold the value you need. If the connection string is in
a specific format, you could also just parse the string, but connection
strings can come in many flavours (see www.connectionstrings.com).
--
Happy Coding!
Hi Morten,
yes, finally I've made like this:
string connString =
ConfigurationManager.ConnectionStrings["PrideConnectionString"].ToString();
SqlConnection connection = new SqlConnection(connString);
string database = connection.DataSource.ToString();
if (database == "MILDBBP2S")
this.lblCurrentEnviroment.Text = "Produzione";
else if (database == "MILDBBP2STEST")
this.lblCurrentEnviroment.Text = "Test";
else
this.lblCurrentEnviroment.Text = "Server unknown";
Thanks so much.
Luigi