private void SetReaderToObject(ref WeaponDamageType objWeaponDamageType, ref SqlDataReader result) { if (result.HasRows) { objWeaponDamageType.WeaponDamageTypeID = (int)result.GetValue(result.GetOrdinal("WeaponDamageTypeID")); objWeaponDamageType.WeaponDamageTypeName = result.GetValue(result.GetOrdinal("WeaponDamageTypeName")).ToString(); objWeaponDamageType.WeaponDamageTypeDescription = result.GetValue(result.GetOrdinal("WeaponDamageTypeDescription")).ToString(); } }
private List <WeaponDamageType> GetWeaponDamageTypeList(string strSprocName, string strWhere, string strOrderBy) { List <WeaponDamageType> WeaponDamageTypes = new List <WeaponDamageType>(); SqlDataReader result; DatabaseConnection dbconn = new DatabaseConnection(); SqlCommand command = new SqlCommand(); SqlConnection connection = new SqlConnection(dbconn.SQLSEVERConnString); try { connection.Open(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = strSprocName; command.Parameters.Add(dbconn.GenerateParameterObj("@strWhere", SqlDbType.VarChar, strWhere, 1000)); command.Parameters.Add(dbconn.GenerateParameterObj("@strOrderBy", SqlDbType.VarChar, strOrderBy, 1000)); result = command.ExecuteReader(); while (result.Read()) { WeaponDamageType objWeaponDamageType = new WeaponDamageType(); SetReaderToObject(ref objWeaponDamageType, ref result); WeaponDamageTypes.Add(objWeaponDamageType); } } catch { Exception e = new Exception(); throw e; } finally { command.Dispose(); connection.Close(); } return(WeaponDamageTypes); }