GetPostsByMonth
获取一个月内所有的帖子
@SectionID=14,表示氯胺酮的Blog
@Year=2005,年份
@Month=10,月份
public override Hashtable GetPostsByMonth(int BlogID, DateTime month)
{
using( SqlConnection connection = GetSqlConnection() )
{
using(SqlCommand command = new SqlCommand(databaseOwner + ".cs_weblog_PostsByMonth", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@SectionID", SqlDbType.Int, 4).Value = BlogID;
//14
//个人blog的记录的ID
command.Parameters.Add("@Year", SqlDbType.Int, 4).Value = month.Year;
//2005
//年
command.Parameters.Add("@Month", SqlDbType.Int, 4).Value = month.Month;
//10
//月
connection.Open();
using(SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult))
{
Hashtable items = new Hashtable();
ArchiveDataItem ad = null;
while(reader.Read())
{
ad = new ArchiveDataItem();
ad.Date = new DateTime((int)reader["Year"],(int)reader["Month"],(int)reader["Day"]);
ad.Count = (int)reader["Count"];
items.Add(ad.Date.Day,ad);
}
reader.Close();
connection.Close();
command.Dispose();
return items;
}
}
}
}



浙公网安备 33010602011771号