当前位置: 代码迷 >> ASP.NET >> 没法将类型“bool”隐式转换为“System.Data.DataTable
  详细解决方案

没法将类型“bool”隐式转换为“System.Data.DataTable

热度:10081   发布时间:2013-02-25 00:00:00.0
无法将类型“bool”隐式转换为“System.Data.DataTable
public Boolean readUserinfo(string tname, string tpassword)
  {
  string[]tuserinfo=new string[3];
  string sqlcommand = "select*from Member where UserName'"+tname+"'and Password='"+tpassword+"'";
  ShoppingCart DB = new ShoppingCart();

  DataTable dt = DB.ExceRead(sqlcommand);
  if (dt.Rows.Count > 0)
  return true;
  else
  return false;
  }

错误 3 无法将类型“bool”隐式转换为“System.Data.DataTable”这是什么意思啊,应该怎么改!!求大虾指点!!

------解决方案--------------------------------------------------------
DB.ExceRead返回应该是bool类型的

DataTable dt = DB.ExceRead(sqlcommand);
if (dt.Rows.Count > 0)
return true;
else
return false;

改成

 return DB.ExceRead(sqlcommand);
  相关解决方案