请教个问题
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TZroom;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from OrderUser where datepart(year,Odata)=datepart(year,getDate()) and datepart(month,Odata)=datepart(month,getdate()) and datepart(day,Odata)=datepart(day,getdate()) and OState=1", con);
int count = Convert.ToInt32(cmd.ExecuteScalar());// 转换
if (cmd.Read())
{
count = cmd.GetInt32(0).ToString();
}
comm.Close();
return count;
有这么写的吗? |