public Networks GetNetworks() { string mainSQL = @"SELECT NetworkID, Organization, NetworkName, LongNetworkName, URL, StationNumber, ObsStartDate, ObsEndDate, LastUpdate, Contact FROM t_Network"; SqlCommand aCommand; SqlDataReader aReader; Networks aNetworkSet = new Networks(); List<NetworksNetwork> aNetworkList = new List<NetworksNetwork>(); using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.enterpriseOD)) { aCommand = new SqlCommand(); aCommand.Connection = conn; aCommand.CommandType = System.Data.CommandType.Text; aCommand.CommandText = mainSQL; conn.Open(); aReader = aCommand.ExecuteReader(); while (aReader.Read()) { NetworksNetwork aNetwork = new NetworksNetwork(); aNetwork.NetworkID = aReader.GetInt32(aReader.GetOrdinal("NetworkID")); aNetwork.Organization = aReader["Organization"].ToString(); aNetwork.NetworkName = aReader["NetworkName"].ToString(); aNetwork.LongNetworkName = aReader["LongNetworkName"].ToString(); aNetwork.URL = aReader["URL"].ToString(); aNetwork.StationNumber = aReader.GetInt32(aReader.GetOrdinal("StationNumber")); if (aReader["ObsStartDate"] is DBNull) aNetwork.ObsStartDateSpecified = false; else { aNetwork.ObsStartDate = aReader.GetDateTime(aReader.GetOrdinal("ObsStartDate")); aNetwork.ObsStartDateSpecified = true; } if (aReader["ObsEndDate"] is DBNull) aNetwork.ObsEndDateSpecified = false; else { aNetwork.ObsEndDate = aReader.GetDateTime(aReader.GetOrdinal("ObsEndDate")); aNetwork.ObsEndDateSpecified = true; } if (aReader["LastUpdate"] is DBNull) aNetwork.LastUpdateSpecified = false; else { aNetwork.LastUpdate = aReader.GetDateTime(aReader.GetOrdinal("LastUpdate")); aNetwork.LastUpdateSpecified = true; } aNetwork.Contact = aReader["Contact"].ToString(); aNetworkList.Add(aNetwork); } aReader.Close(); } aCommand.Dispose(); aNetworkSet.Network = aNetworkList.ToArray(); return aNetworkSet; }