Esempio n. 1
0
 /**
  * @param takes a class of user to insert
  **/
 public void addUser(User u)
 {
     copen();
     String sql = String.Format("INSERT INTO users(email, joindate) VALUES ('{0}','{1}')",u.email,u.joinDate);
     NpgsqlCommand com = new NpgsqlCommand(sql, conn);
     com.ExecuteNonQuery();
     cclose();
 }
Esempio n. 2
0
        /**
         * @param takes a class of user with an id populated
         * @return returns the class that is populated
         **/
        public User getUser(User u)
        {
            copen();
            String sql = String.Format("SELECT id FROM users WHERE email = '{0}'",u.email);
            NpgsqlCommand com = new NpgsqlCommand(sql, conn);
            NpgsqlDataReader dr = com.ExecuteReader();
            dr.Read();
            int num = Int32.Parse(dr[0].ToString());
            u.ID = num;
            cclose();

            return u;
        }