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;
asp.net连接数据库web.config配置
时间: 2024-10-01 05:11:56