web.config 中关于数据库配置
连接字符串格式:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="netElectiveConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=netElective;Persist Security Info=True;User ID=sa;Password=198501" providerName="System.Data.SqlClient" />
</connectionStrings>
页面文件中使用Web.config配置文件中的内容:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:netElectiveConnectionString %>"
SelectCommand="SELECT * FROM [Course]"></asp:SqlDataSource>
posted on 2010-11-18 16:07 Henry_Wang 阅读(212) 评论(0) 编辑 收藏 举报