public List <UserAccountModel> CheckAccountLogin(string Name, string Password) { string query = "select Id, Name, PassWord, Email from UserAccount" + " Where Name = @Name and Password = @Password"; List <UserAccountModel> userAccounts = new List <UserAccountModel>(); List <SqlParameter> parameters = new List <SqlParameter> { new SqlParameter("@Name", Name), new SqlParameter("@Password", Password) }; try { SqlDataReader reader = SqlHelper.ExecuteReader(Startup.ConnectionString, CommandType.Text, query, parameters.ToArray()); if (reader.HasRows) { while (reader.Read()) { UserAccountModel useraccount = new UserAccountModel { Id = reader.GetInt32(0), Name = reader.GetString(1), Password = reader.GetString(2), Email = reader.GetString(3), }; userAccounts.Add(useraccount); } } else { Console.WriteLine("No rows found."); } reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(userAccounts); }
public List <UserAccountModel> ListUserName(string Name) { string query = "select Name from UserAccount" + " where Name = @Name"; List <UserAccountModel> userAccounts = new List <UserAccountModel>(); List <SqlParameter> parameters = new List <SqlParameter> { new SqlParameter("@Name", Name), }; try { SqlDataReader reader = SqlHelper.ExecuteReader(Startup.ConnectionString, CommandType.Text, query, parameters.ToArray()); if (reader.HasRows) { while (reader.Read()) { UserAccountModel useraccount = new UserAccountModel { Name = reader.GetString(0), }; userAccounts.Add(useraccount); } } else { Console.WriteLine("No rows found."); } reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(userAccounts); }