Returning values
-
Hi, I hope someone can help. I have to import some data from a text file into a database. The text files are loaded into a datagrid to be previewed and validated before being imported. There are some conditions to the import, each child record must have a pre-existing parent record before it will be imported etc. The validation is handled in a stored procedure. What I need to do is return all of the values that have failed to import in a collection. public ItemEventCollection failures = null; ... public ItemEventCollection EventImport(SecurityContext sc, ItemEventCollection EventCollection) { if (EventCollection != null) { foreach (ItemEvent itemEvent in EventCollection) { try { ItemEventInsertCommand.Execute(DataAccessManager(sc), itemEvent); } catch { failures.Add(ItemEvent); } } } return failures; } If I step through the code, failures always has a count of 0 when I know there are rows failing the import conditions. I need to add them to failures then pass it back to a datagrid. How? Do I use the out keyword or simply return the ItemEventCollection, I'm really stumped on this one, please can someone help? Best regards Scott ;)