5

I was wondering what is the difference in having connection strings in 2 app settings and connectionstrings? Just wanted to know technically in Visual Studio 2008 for windows authentication!

<appSettings>
    add key="ConnectionString" value="Server=198.57.2.70;Database=SalesTracking;Integrated Security=SSPI"  />       
</appSettings>

<connectionStrings>
<add name="ConnectionString" connectionString="DataSource=198.57.2.70;InitialCatalog=SalesTracking;IntegratedSecurity=True;" />
</connectionStrings>

Thanks!!

StingyJack
  • 19,041
  • 10
  • 63
  • 122
challengeAccepted
  • 7,106
  • 20
  • 74
  • 105
  • possible duplicate of [purpose of ConnectionString element in .NET .config files](http://stackoverflow.com/questions/3400330/purpose-of-connectionstring-element-in-net-config-files) – StingyJack Jul 11 '13 at 21:09

1 Answers1

3

The difference is that the connectionString section gives you strongly typed access to your connection strings through the ConfigurationManager class. It's meant for connection strings specifically.

AppSettings is meant to store general settings. You can use it to store connection strings, but I recommend not doing that since there is a specific element for it in connectionStrings

TGH
  • 38,769
  • 12
  • 102
  • 135
  • Or, if you want to use the "file" attribute to merge/override settings, like connection strings. "configSection" doesn't do this. – Piotr Kula Nov 28 '14 at 10:26