web.config配置如下:
<connectionStrings> <add name="myConn" connectionString="Data Source=localhost;Initial Catalog=db_student;uid=sa;pwd=123456" providerName="System.Data.SqlClient"/> </connectionStrings>
连接字符串:
string connectionString = WebConfigurationManager.ConnectionStrings["myConn"].ConnectionString;
其中需要引用:
using system.web.configuration;
本文出自 “牧尹御林” 博客,请务必保留此出处http://wongcony.blog.51cto.com/7188824/1539269