Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Returning values

Returning values

Scheduled Pinned Locked Moved C#
databasehelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scotlandc
    wrote on last edited by
    #1

    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 ;)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups