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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. BeginLoadData()?????

BeginLoadData()?????

Scheduled Pinned Locked Moved C#
databasequestion
2 Posts 2 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.
  • T Offline
    T Offline
    Twyce
    wrote on last edited by
    #1

    The following code is supposed to be comparing two datasets and then load the rows that are not duplicates into a third datatable.Instead it repeats the rows that are already in the database(making more duplicates).Could someone tell me what i am doing wrong. foreach (DataRow parentrow in dsImport.Tables[2].Rows) { DataRow[] childrows = parentrow.GetChildRows(r); if (childrows == null || childrows.Length == 0) dtImport.LoadDataRow(parentrow.ItemArray, true); } foreach (DataRow databaseRow in dsImport.Tables["StudentModule"].Rows) { foreach (DataRow spreadRow in dsImport.Tables["Sheet1$"].Rows) { if (spreadRow != databaseRow) { dtImport.BeginLoadData(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return dtImport

    H 1 Reply Last reply
    0
    • T Twyce

      The following code is supposed to be comparing two datasets and then load the rows that are not duplicates into a third datatable.Instead it repeats the rows that are already in the database(making more duplicates).Could someone tell me what i am doing wrong. foreach (DataRow parentrow in dsImport.Tables[2].Rows) { DataRow[] childrows = parentrow.GetChildRows(r); if (childrows == null || childrows.Length == 0) dtImport.LoadDataRow(parentrow.ItemArray, true); } foreach (DataRow databaseRow in dsImport.Tables["StudentModule"].Rows) { foreach (DataRow spreadRow in dsImport.Tables["Sheet1$"].Rows) { if (spreadRow != databaseRow) { dtImport.BeginLoadData(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return dtImport

      H Offline
      H Offline
      Harvey Saayman
      wrote on last edited by
      #2

      first off, PLEASE use pre tags for code blocks... second, why not create primary or unique keys on your datatables? that should help with the duplicates

      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

      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