<connectionStrings>
      <add  name = "" [String, Required, Collection Key]   connectionString = "" [String, Required]  providerName = "System.Data.SqlClient" [String]   />
</connectionStrings>
<connectionStrings>
        <clear />
        <add name="LocalSqlServer" connectionString="data source=./SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
    </connectionStrings>
string strConnection = ConfigurationManager.ConnectionStrings["mdbconn"].ToString();
SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrings["mdbconn"].ConnectionString);
 

本文转载:CSDN博客