예제 #1
0
 //插入 评论记录
 public bool save(Reviews re)
 {
     string sql = "insert into t_Reviews(weiboId,reAuthorId,reAuthorName,returnContent,reTime) values("+ re.weiboId+","+
         re.reAuthorId + ",'"+ re.reAuthorName  + "','" +re.returnContent+ "','" + re.reTime + "')";
     int flag = DBHelper.ExecuteSQL(sql);
     if (flag == 1)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #2
0
        //根据sql查询评论信息
        IList<Reviews> GetReviewsBySql(string sql)
        {
            SqlDataReader reader = DBHelper.ExecuteReader(sql);
            IList<Reviews> Reviews = new List<Reviews>();
            try
            {
                while (reader.Read())
                {
                    Reviews re = new Reviews();
                    re.reviewId = Convert.ToInt32(reader["reviewId"]);
                    re.weiboId = Convert.ToInt32(reader["weiboId"]);
                    re.reAuthorId = Convert.ToInt32(reader["reAuthorId"]);
                    re.reAuthorName = reader["reAuthorName"].ToString();
                    re.returnContent = reader["returnContent"].ToString();
                    re.reTime = (DateTime)reader["reTime"];
                    Reviews.Add(re);
                }

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return Reviews;
        }