string str = ConfigurationManager.ConnectionStrings["MySchool"].ConnectionString;未引用对象的实例
connectionString.xml文件如下:<?xmlversion="1.0"encoding="utf-8"?><configuration><connecti...
connectionString.xml文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionstrings>
<add name="DataBaseOwner" connectionString="dbo"/>
<add name="MySchool" connectionString="Data Source=.;Initial Catalog=MySchool;Integrated Security=True"/>
</connectionstrings>
</configuration>
调用如下:
private readonly string constr = ConfigurationManager.ConnectionStrings["MySchool"].ConnectionString;未将对象引用设置到对象的实例
我引用了using System.Configuration; 展开
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionstrings>
<add name="DataBaseOwner" connectionString="dbo"/>
<add name="MySchool" connectionString="Data Source=.;Initial Catalog=MySchool;Integrated Security=True"/>
</connectionstrings>
</configuration>
调用如下:
private readonly string constr = ConfigurationManager.ConnectionStrings["MySchool"].ConnectionString;未将对象引用设置到对象的实例
我引用了using System.Configuration; 展开
2个回答
展开全部
你的内容,必须放在 web.config 或者 app.config 里面, 而不是放在 connectionString.xml
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询