sqlhelper的用法
我用petshop4.0里的sqlhelper:
SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.StoredProcedure, "newstypeblind ");
报错:“SqlHelper”的类型初始值设定项引发异常。这是怎么回事?
SqlHelper.ConnectionStringLocalTransaction是sqlhelper里的:public static readonly string ConnectionStringLocalTransaction = ConfigurationManager.ConnectionStrings[ "connstring "].ConnectionString;
------解决方案--------------------ConfigurationManager.ConnectionStrings[ "connstring "].ConnectionString;
这个在webconfig里面有设置吗?
------解决方案--------------------web.config里面要加上连接字符串的信息,比如:
<connectionStrings>
<add name= "connstring " connectionString= "server=Server;database=Database; " />
</connectionStrings>
------解决方案--------------------你说的这个在SqlHelper中没有,不过你可以在web.config自己设置好后,传递给SqlHelper相应的方法