配置文件中的代码:
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="自定义名称"
connectionString="server=.;database= 数据库名称;Trusted_Connection=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
后台文件代码:创建的本地数据库.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["自定义名称 "].ToString();
|