I'm writing a windows service and I need the list of all connection strings defined in App.config.
I Used System.Configuration.ConfigurationManager.ConnectionStrings to get all connections.
it always return this extra connection:
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
that I think is added in machine.config.
my App.config is:
<add name="AvmPortalConnectionString"
connectionString="Data Source=.;Initial Catalog=AvmPortal;Integrated Security=True"
providerName="System.Data.SqlClient" />
Is there anyway that I can get only connection Strings defined in App.config(not the one in machine.config)
I can remove this, but I wonder if there is a cleaner way!
Thanks
Try adding a clear before the add:
<connectionStrings>
<clear />
<add name="AvmPortalConnectionString"
connectionString="Data Source=.;Initial Catalog=AvmPortal;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With