做一个winform程序,怎么把select avg...(平均数)这个查询的值放到窗体的label控件中去?
展开全部
public static int GetAvg()
{
sql = select avg(列名) from 表名 [where ......] ;
conn = "server=.;database=.;user=.;pwd=.";
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
return cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
{
sql = select avg(列名) from 表名 [where ......] ;
conn = "server=.;database=.;user=.;pwd=.";
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
return cmd.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询