DR = cmd.ExecuteScalar();是进行错误并返回错误请检查并解决此错误先生 [英] dr=cmd.ExecuteScalar(); it is conduct the error and return a conduct the error please check and solve this error sir please

查看:67
本文介绍了DR = cmd.ExecuteScalar();是进行错误并返回错误请检查并解决此错误先生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public int membercount(string tbl, string condition)
{
  string query = null;
  if (condition.Trim().Length > 0) 
  {
    query = query + "where" + condition;
  }
  else
  {
    query = query;
  }
  cmd = new SqlCommand(query, con);
  dr = cmd.ExecuteScalar();
  return a;
}

'



[edit]已添加代码块[/ edit]

´

[edit]Code block added[/edit]

推荐答案

在代码中......即使查询为null,你也会传递给 cmd 并且你正试图执行查询...可能是错误..尝试为查询指定一些值如果它是Null ..或者你可以在中执行 cmd if(condition.Trim()。Length> 0) cond 'n



希望这个解释有效......
In the Code.... Even though query is null u are passing to cmd and u are trying to execute query... May be it's the error.. Try assign some value to query if it's Null.. or u can execute cmd in if (condition.Trim().Length > 0) cond'n

Hope this explanation Works...


这篇关于DR = cmd.ExecuteScalar();是进行错误并返回错误请检查并解决此错误先生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆