string sql="select count(*) from qcqg where uid='2'";
cmd = new SqlCommand(sql,conn);
int i=(int)cmd.ExecuteScalar();
if(i>0)
countreg=i;
else
Response.Write (目前还没有任何信息!");
cmd = new SqlCommand(sql,conn);
int i=(int)cmd.ExecuteScalar();
if(i>0)
countreg=i;
else
Response.Write (目前还没有任何信息!");
要绑定数据在DataGrid或DataList,如果绑定的不是count(i)的值,当然还应该写另一条sql语句,类似这样:
sql="select * from qcqg where uid='2'";
SqlDataAdapter adapter=new SqlDataAdapter(sql,conn);
DataTable table=new DataTable();
adapter.Fill(table);
DataGrid1.DataSource=table;
DataGrid1.DataBind();
theLabel.Text = read.GetValue(0).ToString();
else
theLabel.Text = "目前还没有任何信息!";