| |||||||||||||||
<connectionStrings> SectionASP.NET Syntax ASP.NET Configuration Sections .NET Framework version 2.0 Specifies a collection of database connection strings, as name/value pairs, for ASP.NET applications and features. <connectionStrings > <add /> <clear /> <remove /> </connectionStrings> Attributes and ElementsThe following sections describe attributes, child elements, and parent elements for this element. AttributesNone, except the attributes that are inherited by all section elements. Child Elements
Parent Elements
RemarksThe connectionStrings element specifies a collection of database connection strings, as name/value pairs, for ASP.NET applications and features. In previous versions of ASP.NET, connection strings were stored in the appSettings. In ASP.NET 2.0, features, such as Session, Membership, Personalization, and Role Manager, rely on connection strings that are stored in the connectionStrings element. You can also use the connectionStrings element to store connection strings for your own applications. Default ConfigurationConnection strings that are contained in a parent configuration file are inherited, unless the clear element is used in the child configuration file. The following default connectionStrings element is configured in the Machine.config file. <connectionStrings>
<add name = "LocalSqlServer"
connectionString = "data source=.\SQLEXPRESS;Integrated Security=SSPI;
AttachDBFilename= | DataDirectory | aspnetdb.mdf;User Instance=true"
providerName = "System.Data.SqlClient" />
</connectionStrings>
ExampleThe following code example demonstrates how to configure two connection strings. The first connection string can be used by an ASP.NET application and the second connection string is used by the sqlCacheDependency element, which is configured later. <configuration>
<!-- Other configuration settings -->
<connectionStrings>
<add name = "Sales"
providerName = "System.Data.SqlClient"
connectionString= "server=myserver;database=Products;uid=salesUser;pwd=sellMoreProducts" />
<add name = "NorthWind"
providerName = "System.Data.SqlClient"
connectionString = "server=.;database=NorthWind;Integrated Security=SSPI" />
</connectionStrings>
<cache>
<sqlCacheDependency enabled = "true" pollTime = "60000">
<databases>
<add name = "Northwind" />
</databases>
</sqlCacheDependency>
</cache>
</configuration>
See AlsoASP.NET Configuration ConnectionStringsSection Class ConnectionStringSettings Class ConnectionStringSettingsCollection Class |
| ||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme