Exemple #1
0
 public Role GetRole(int id)
 {
     Role role = new Role();
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         string command = String.Format(@"SELECT * FROM tblAdminRole WHERE Id={0}", id);
         using (SqlCommand cmd = new SqlCommand(command, connection))
         {
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                if(reader.Read())
                {
                    return this.ReadRole(reader);
                }
                else
                {
                    return null;
                }
             }
         }
     }
 }
Exemple #2
0
 private Role ReadRole(SqlDataReader reader)
 {
     Role role = new Role();
     role.ID = (int)reader["Id"];
     role.Value = (string)reader["Role"];
     return role;
 }