示例#1
0
 public Credential GetCredential(int id)
 {
     Credential cred = new Credential();
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         string command = String.Format(@"SELECT * FROM tblAdminCredential WHERE AdminId={0}", id);
         using (SqlCommand cmd = new SqlCommand(command, connection))
         {
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     return this.ReadCredential(reader);
                 }
                 else
                 {
                     return null;
                 }
             }
         }
     }
 }
示例#2
0
 private Credential ReadCredential(SqlDataReader reader)
 {
     Credential cred=new Credential();
     cred.ID=(int)reader["Id"];
     cred.AdminID=(int)reader["AdminId"];
     cred.Login=(string)reader["Login"];
     cred.Password=(string)reader["Password"];
     cred.RoleID=(int)reader["RoleId"];
     return cred;
 }