本来很简单的问题,去被大家弄的那么复杂。
SqlConnection conn=new SqlConnection();
String constr=ConfigurationSettings.AppSettings["sql"];
conn.ConnectionString=constr;
conn.Open();
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select count(*) from ProductsTable where CoID= '"+newsid+"'";
int count;
count= ????;就是这里,我的要求很简单,就是获取ProductsTable中的CoID= '"+newsid+"'的记录一共多少条?这个很难吗?刚才发了个帖子,回复了10条,我楞没找到答案!晕
cmd.Connection=conn;
SqlDataReader dr=cmd.ExecuteReader();
if (dr.Read())
{
while(count>0)
{ ......(这里是用label显示在页面上的)
count=count-1;
}
}
SqlConnection conn=new SqlConnection();
String constr=ConfigurationSettings.AppSettings["sql"];
conn.ConnectionString=constr;
conn.Open();
SqlCommand cmd=new SqlCommand();
cmd.CommandText="select count(*) from ProductsTable where CoID= '"+newsid+"'";
int count;
count= ????;就是这里,我的要求很简单,就是获取ProductsTable中的CoID= '"+newsid+"'的记录一共多少条?这个很难吗?刚才发了个帖子,回复了10条,我楞没找到答案!晕
cmd.Connection=conn;
SqlDataReader dr=cmd.ExecuteReader();
if (dr.Read())
{
while(count>0)
{ ......(这里是用label显示在页面上的)
count=count-1;
}
}
解决方案 »
- 如何在Repeater中使用PopupControlExtender?
- 存储过程执行时总提示 未提供该参数
- 关于JavaScript处理服务器端的异常!
- 有没有办法主动使页面输出缓存过期?
- 怎么给绑定的数据添加连接,是绑在 DataList 里的??
- ASP.NET登录SQL SERVER2000失败
- 关于DeviceSpecific查找控件问题
- 讨论一下profile方案
- 请教纯数学问题:如何在image中,显示y=sin(x)图形?
- 怎样把(服务器控件)TextBox设成一个隐藏域,急!
- 请教各位大虾一个datagrid绑定第一列“序号”列能让它逐一递增的实现问题,在线等待!
- Microsoft Visual Studio .NET 2003调试不了!
MyAdapter = new OleDbDataAdapter(sql,Conn);
DataSet ds=new DataSet();
MyAdapter.Fill(ds,TableName);
int count;
count=ds.Table[0].Rows.Count;