本来很简单的问题,去被大家弄的那么复杂。
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;
}
}