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;
            }

        }

    }

}


posted on 2005-10-18 11:16  Konimeter  阅读(254)  评论(0)    收藏  举报