1.存储过程:
CREATE PROCEDURE hlsj
(@month int,
@year int,
@CityId int)
AS
BEGIN
SET NOCOUNT ON;
select top 100 count(ProcessedInput) as sl,ProcessedInput from 表名 where [month]=@month and [year]=@year and CityId=@CityId group by ProcessedInput order by sl desc
END
GO
2.数据绑定,显示:
SqlParameter[] para = new SqlParameter[3];
para[0] = new SqlParameter("@month",int.Parse(DropDownList2.SelectedValue));
para[1] = new SqlParameter("@year", int.Parse(DropDownList3.SelectedItem.Text.ToString().Trim()));
para[2] = new SqlParameter("@CityId", int.Parse(DropDownList1.SelectedValue));
List<hl> list_art = new List<hl>();
using (SqlDataReader reader = Article.SqlHelper.sqlexc.GetReader("hlsj", para))
{
while (reader.Read())
{
hl art = new hl();
art.input = reader["ProcessedInput"].ToString();
art.count = Convert.ToInt32(reader["sl"].ToString());
list_art.Add(art);
}
Article.SqlHelper.sqlexc.con.Close();
}
gvadm.DataSource = list_art;
gvadm.DataBind();
3.创建分区和索引:
参考 文章: