在线等待[马上结分]:用SqlDataReader怎么得到一个查询语句的记录数? 用Command对象的ExecuteScalar()方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比如:public int GetRowCount(string sql){ try { int count; object temp; Open(); myCommand =new SqlCommand(sql,myConnection); temp=myCommand.ExecuteScalar(); if(temp==System.DBNull.Value) count=0; else count=int.Parse(temp.ToString()); return count; } catch { myConnection.Close(); return 0; }} 类似CAD在网页上拖动图标,最后组成一张图(求思路) sql2000中获取最后一个ID,急啊 谁知道在Panel 容器中动态添加文本框! 请教:在WEB项目中有什么比较好的方式统一处理异常和登陆超时? 请教,DataGrid的单击事件 怎么才能将数据库中的0和1转换成男和女 求,页面自动刷新代码 看成败人生豪迈,只不过是从头再来啊啊 如何解决控件问题:checklistbox和calendar??? 大虾帮忙呀! 关于传递参数问题! 高手请过目,关于System.Windows.Forms的DataGrid问题
public int GetRowCount(string sql)
{
try
{
int count;
object temp;
Open();
myCommand =new SqlCommand(sql,myConnection);
temp=myCommand.ExecuteScalar(); if(temp==System.DBNull.Value)
count=0;
else
count=int.Parse(temp.ToString()); return count;
}
catch
{
myConnection.Close();
return 0;
}
}