public Boolean isExist(User user) { DB_Dao dbDao = new DB_Dao(); String sqlSearch = "select * from user where username = '******' and psw = '" + user.Password + "'"; MySqlDataReader reader = dbDao.getReader(sqlSearch); while (reader.Read()) { return(true); } return(false); }
public User getUserById(String id) { DB_Dao dbDao = new DB_Dao(); String sql = "select * from user where id=" + id; MySqlDataReader reader = dbDao.getReader(sql); User user = new User(); while (reader.Read()) { user.Id = reader.GetString("id"); user.Username = reader.GetString("username"); user.Password = reader.GetString("psw"); user.Nickname = reader.GetString("nickname"); } return(user); }
public List <User> getAllUsers() { List <User> list = new List <User>(); DB_Dao dbDao = new DB_Dao(); String sql = "select * from user"; MySqlDataReader reader = dbDao.getReader(sql); while (reader.Read()) { User user = new User(); user.Id = reader.GetString("id"); user.Username = reader.GetString("username"); user.Password = reader.GetString("psw"); user.Nickname = reader.GetString("nickname"); list.Add(user); } return(list); }