Hi All,
In my winform application I use Linq to Sql.
My app.config file is following code
- "1.0" encoding="utf-8"?>
-
-
-
"SmartexFxDashboard.Properties.Settings.smartex_fx_reportsConnectionString" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=smartex_fx_reports;Integrated Security=True" providerName="System.Data.SqlClient"/> -
-
"v4.0" sku=".NETFramework,Version=v4.6.1"/>
1. Server name
2. Instance name
Now if I have default instance I need to write
(local)
And in case I have names instance e.g. SQLEXPRESS I need to write
(local)/SQLEXPRESS
But I didn't know in client computer he have which instance. So, I need to know the instance name and save in key and instead of SQLEXPRESS I use that key.
In MS SQL SERVER 2008 if I execute query
- select @@SERVERNAME
- select @@SERVICENAME
So, I need your expertise how I get this instance name in app.config file and save in key and use it. So it's not hard coded and work for all.
Advance thanks and looking forward to your answers.

Mageshwaran RPosted Nov 15, 2019, 5:28 AM
Amit GuptaPosted Oct 26, 2018, 3:12 AM
Salman MushtaqPosted Oct 26, 2018, 3:04 AM
Amit GuptaPosted Oct 26, 2018, 2:52 AM
Salman MushtaqPosted Oct 25, 2018, 4:38 PM
Amit GuptaPosted Oct 25, 2018, 10:05 AM
select @@SERVICENAME