// Return number of records inserted or found.
        public static int HandleMethodsInfo(SqlConnection sqlConn, MethodType m)
        {
            Console.WriteLine(">>>Parsing and inserting METHODS");

            // Check if MethodID is already in the table or not
            string cond = "MethodID = " + m.methodID;

            if (OD_Utils.Exists("Methods", cond, sqlConn))
            {
                return(1);
            }

            string sql = string.Format(@"SET IDENTITY_INSERT [Methods] ON;
INSERT INTO Methods (MethodID, MethodDescription, MethodLink)
VALUES ({0}, '{1}', '{2}');
SET IDENTITY_INSERT [Methods] OFF",
                                       m.methodID,
                                       m.methodDescription,
                                       m.methodLink);

            return(OD_Utils.RunNonQuery(sql, sqlConn));
        }
        static int InsertOneMetadata(MetaDataType m, SqlConnection sqlConn)
        {
            string sql;

            if (m != null)
            {
                sql = string.Format(@"INSERT INTO ISOMetadata ([TopicCategory],[Title],[Abstract],[ProfileVersion],[MetadataLink]) 
                    VALUES ('{0}', '{1}', '{2}', '{3}', '{4}')",
                                    m.topicCategory,
                                    m.title,
                                    m.@abstract,
                                    m.profileVersion,
                                    m.metadataLink);
            }
            else
            {
                sql = @"INSERT INTO ISOMetadata ([TopicCategory],[Title],[Abstract],[ProfileVersion],[MetadataLink]) 
                    VALUES ('Unknown', 'Unknown', 'Unknown', 'Unknown', 'Unkown')";
            }

            return(OD_Utils.RunNonQuery(sql, sqlConn));
        }
        static void InsertOneSource(OD_1_1_1DataSet.SourcesDataTable srcTable,
                                    SiteInfoType stinfo, seriesCatalogTypeSeries scts, TimeSeriesType tst,
                                    int metadataID, SqlConnection sqlConn)
        {
            OD_1_1_1DataSet.SourcesRow row = srcTable.NewSourcesRow();

            row.SourceID          = scts.source.sourceID;
            row.Organization      = scts.source.organization;
            row.SourceDescription = scts.source.sourceDescription;

            row.MetadataID = metadataID;

            string tbd = "TBD";

            row.SourceLink = tbd;
            if (scts.source.sourceLink != null)
            {
                row.SourceLink = scts.source.sourceLink[0];
            }

            row.ContactName     = row.Phone = row.Email =
                row.Address     = row.City = row.State =
                    row.ZipCode = row.Citation = tbd;

            for (int i = 0; (stinfo.note != null) && (i < stinfo.note.Count()); i++)
            {
                NoteType note = stinfo.note[i];
                switch (note.title)
                {
                case "ContactName":
                    row.ContactName = note.Value;
                    break;

                case "Phone":
                    row.Phone = note.Value;
                    break;

                case "Email":
                    row.Email = note.Value;
                    break;

                case "Address":
                    row.Address = note.Value;
                    break;

                case "City":
                    row.City = note.Value;
                    break;

                case "State":
                    row.State = note.Value;
                    break;

                case "ZipCode":
                    row.ZipCode = note.Value;
                    break;

                case "Citation":
                    row.Citation = note.Value;
                    break;
                }
            }

            //srcTable.AddSourcesRow(row);
            string sql = string.Format(@"SET IDENTITY_INSERT [Sources] ON;
INSERT INTO [Sources] 
([SourceID], [Organization], [SourceDescription], [SourceLink],
[ContactName], [Phone], [Email], [Address], [City], [State], [ZipCode],
[Citation], [MetadataID])
VALUES ({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', {12});
SET IDENTITY_INSERT [Sources] OFF",
                                       row.SourceID, row.Organization, row.SourceDescription, row.SourceLink,
                                       row.ContactName, row.Phone, row.Email, row.Address, row.City, row.State, row.ZipCode,
                                       row.Citation, row.MetadataID);

            OD_Utils.RunNonQuery(sql, sqlConn);
        }