怎么设置asp项目的数据库信息
在web.config文件中:<addname="DB"connectionString="server=.\sqlexpress;database=StudentInf...
在web.config文件中:
<add name="DB" connectionString="server=.\sqlexpress;database=StudentInfo;Integrated security =false;uid=sa;pwd=123;" />
<add name="DB" connectionString="server=.\sqlexpress;database=StudentInfo;Integrated security = true;" />这两种是一样的吗 展开
<add name="DB" connectionString="server=.\sqlexpress;database=StudentInfo;Integrated security =false;uid=sa;pwd=123;" />
<add name="DB" connectionString="server=.\sqlexpress;database=StudentInfo;Integrated security = true;" />这两种是一样的吗 展开
2016-06-09 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
第一种:
取连接字符串
string connString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["SqlConnStr"].ConnectionString;
或者
protected static string connectionString = ConfigurationManager.ConnectionStrings["SqlConnStr"].ConnectionString;
web.config文件:加在</configSections>后面
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="SqlConnStr" connectionString="user id=xx;password=xx;initial catalog=database_name;data source=.\sqlxxxx" />
</connectionStrings>
取连接字符串
string connString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["SqlConnStr"].ConnectionString;
或者
protected static string connectionString = ConfigurationManager.ConnectionStrings["SqlConnStr"].ConnectionString;
web.config文件:加在</configSections>后面
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="SqlConnStr" connectionString="user id=xx;password=xx;initial catalog=database_name;data source=.\sqlxxxx" />
</connectionStrings>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询