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.


Amit GuptaRank #190 · 12.8K reputationPosted Oct 25, 2018, 6:05 AM EDT
select @@SERVICENAME
Salman MushtaqRank #6,413 · 267 reputationPosted Oct 25, 2018, 12:38 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Oct 25, 2018, 10:52 PM EDT
Salman MushtaqRank #6,413 · 267 reputationPosted Oct 25, 2018, 11:04 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Oct 25, 2018, 11:12 PM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 15, 2019, 12:28 AM EST