Beispiel #1
0
        public static int ThemThacMac(ThacMac tm)
        {
            string query = String.Format("INSERT INTO ThacMac(Ten, Email, TieuDe, NoiDung) VALUES (N'" + tm.Ten + "', N'" + tm.Email + "', N'" + tm.TieuDe + "', N'" + tm.NoiDung + "')");

            try
            {
                conn.Open();
                command.CommandText = query;
                return command.ExecuteNonQuery();

            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }
            return 0;
        }
Beispiel #2
0
 public static ArrayList LayThacMacTheoEmail(string mail)
 {
     ArrayList list = new ArrayList();
     string sql = String.Format("SELECT * FROM ThacMac WHERE Email = '"+ mail +"' and Status = 1");
     try
     {
         conn.Open();
         command.CommandText = sql;
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             string ten = reader.GetString(1);
             string email = reader.GetString(2);
             string tieude = reader.GetString(3);
             string noidung = reader.GetString(4);
             ThacMac tm = new ThacMac(ten,  email, tieude, noidung);
             list.Add(tm);
         }
     }
     finally
     {
         conn.Close();
     }
     return list;
 }