日期:2014-05-17  浏览次数:20422 次

无法将类型“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);