“ElevatorDAL.MySqlHelper”的类型初始值设定项引发异常。

葫芦娃快救爷爷 2017-09-25 04:03:46

代码如下
public static DataTable List(string id)
{
try
{
MySqlCommand sqlcom = new MySqlCommand();
sqlcom.CommandText = "select * from mt_userrole where UserID=@id";
MySqlParameter commandParameters = new MySqlParameter("@id", id);
MySqlDataReader reader = MySqlHelper.ExecuteReader(MySqlHelper.ConnectionStringManager, CommandType.Text, sqlcom.CommandText, commandParameters);
DataTable dt = DataReaderToDataTable(reader);
if (dt.Rows.Count > 0)
return dt;
else
return null;

}
catch (Exception ex)
{
string _error = ex.Message.ToString();

return null;
}
}

web.config如下
<configuration>
<!-- 连接数据库-->
<connectionStrings>
<add name="Connection Strings" connectionString="Server=192.168.0.85;Max Pool Size = 2048;Database=elevator3.3; User ID=root; Password=******;Charset=utf8;default command timeout=150;connection timeout=300;" providerName="MySql.Data.MySqlClient"/>
<add name="MySQLConnString" connectionString="Server=192.168.0.85;Max Pool Size = 2048;Database=elevator3.3; User ID=root; Password=******;Charset=utf8;default command timeout=150;connection timeout=300;" providerName="MySql.Data.MySqlClient"/>

</connectionStrings>
<appSettings>
...全文
278 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
exception92 2017-09-25
  • 打赏
  • 举报
回复
“查看详细信息” 并调试你的程序http://www.cnblogs.com/alexis/archive/2010/11/06/1870519.html
  • 打赏
  • 举报
回复

web.config的配置没问题吧,别的方法用没有问题
  • 打赏
  • 举报
回复

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧