sq查询
SqlCommand cmdm = new SqlCommand( "select *from dbv_mcpagg where recorddate= ' " + Date.ToString( "yyyy-MM-dd ") + " ' ", conn);
SqlDataReader strm = cmdm.ExecuteReader();
while (strm.Read())
{
this.bmc_prod.Text = strm[ "production "].ToString();
this.bmc_tot.Text = strm[ "totalqty "].ToString();
}
strm.Close();
//------------------------------------------------------------------------
SqlCommand cmddt = new SqlCommand( "select *from dbv_dtagg where recorddate= ' " + Date.ToString( "yyyy-MM-dd ") + " ' ", conn);
SqlDataReader strdt = cmddt.ExecuteReader();
while (strdt.Read())
{
this.bmc_dt.Text = strdt[ "Downtime "].ToString();
}
strdt.Close();
假如一个页面中有几十个要查询的,而且每个要查询的数据都不在同一个数据库,那不是要重复写很多了啊,有没有什么简便的方法?
------解决方案--------------------你可以寫一個通用方法嘛
傳SQL進去
返回一個DataReader