Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App.config - LocalSqlServer connection string

Tags:

vb.net

Please see the code below:

Public Shared Sub SyncConnectionStrings()
    Dim strCon As String
    Dim tyDatabase As typeDatabase
    Dim boolConfigChanged As Boolean
    'Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
    Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
    Dim strConnectionString As ConnectionStringSettings            
    For Each strConnectionString In ConfigurationManager.ConnectionStrings
        'More code here, but irrelevant for this question.
    Next
End Sub

The code loops through all the connection strings in the app.config file. There are three connection strings in the app.config, but four connection strings are found. Where is: LocalSqlServer (this is the ConfigurationManager.ConnectionStrings.Name) defined?

like image 732
w0051977 Avatar asked May 07 '13 10:05

w0051977


1 Answers

It is defined in the Machine.config global file located at

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG".

It is generated when you install the NET.Framework and is needed by tools that work on the ASPNETDB

If you don't need it, you could try to add this to your app.config

<connectionStrings>
<clear/>
.....

or also

<connectionStrings>
<remove name="LocalSqlServer" />

I really suggest to not change anything in Machine.Config unless you know the side effects.

like image 74
Steve Avatar answered Sep 21 '22 05:09

Steve