diff --git a/DATabaseTwo/Import.cs b/DATabaseTwo/Import.cs index 4b7c94fb..552b5f77 100644 --- a/DATabaseTwo/Import.cs +++ b/DATabaseTwo/Import.cs @@ -128,7 +128,7 @@ COMMIT;"; string source = GetSourceFromFileName(Path.GetFileName(file)); int sourceid = 0; - Dictionary sources = new Dictionary(); + SortedDictionary sources = new SortedDictionary(); sources.Add("default", 0); query = "SELECT name, id FROM source"; using (SqliteCommand sslc = new SqliteCommand(query, dbc)) @@ -208,13 +208,27 @@ COMMIT;"; // Otherwise, get the ID else if (source != "" && sourceid == 0 && sources.ContainsKey(source)) { - sourceid = sources[source.ToLowerInvariant()]; + try + { + sourceid = sources[source.ToLowerInvariant()]; + } + catch + { + sourceid = 0; + } } // Otherwise, we should already have an ID } else { - sourceid = sources[source.ToLowerInvariant()]; + try + { + sourceid = sources[source.ToLowerInvariant()]; + } + catch + { + sourceid = 0; + } } // Add the source and system link to the database