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. Loading Datasets

Loading Datasets

Scheduled Pinned Locked Moved C#
databasehelp
3 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.
  • M Offline
    M Offline
    MAW30
    wrote on last edited by
    #1

    I am trying to load up a dataset from an SQL table, after the first row the code is exited at the following line: dr = dt.NewRow(); There are 10,000 lines in the SQL table do you have any ideas on why this is happening. DataSet_I.BSDDataTable BSD = new DataSet_I.BSDDataTable(); if (strTableName == "xxxxx") { dt = BSD; if (Rowset != null && Rowset.IsOpen) { int nCol = 0; //int nCols = Rowset.Cols; Rowset.MoveFirst(); while (!Rowset.IsEOF) { dr = dt.NewRow(); **************EXITS CODE on 2nd PASS****************** foreach (DataColumn dc in dt.Columns) { nCol++; object dcValue = Rowset.GetData(nCol); if (dcValue != null) { if (dc.DataType == typeof(System.String)) dr[dc] = (string)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Int32)) dr[dc] = (int)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Single)) dr[dc] = (float)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.DateTime)) dr[dc] = (DateTime)Rowset.GetData(nCol); } } dt.Rows.Add(dr); Rowset.MoveNext(); } } Also, can I assign a set number of rows to the DataTable before I start and just load without adding new rows. Any help would be greatly appreciated. Thanks in advance. Michael

    S 1 Reply Last reply
    0
    • M MAW30

      I am trying to load up a dataset from an SQL table, after the first row the code is exited at the following line: dr = dt.NewRow(); There are 10,000 lines in the SQL table do you have any ideas on why this is happening. DataSet_I.BSDDataTable BSD = new DataSet_I.BSDDataTable(); if (strTableName == "xxxxx") { dt = BSD; if (Rowset != null && Rowset.IsOpen) { int nCol = 0; //int nCols = Rowset.Cols; Rowset.MoveFirst(); while (!Rowset.IsEOF) { dr = dt.NewRow(); **************EXITS CODE on 2nd PASS****************** foreach (DataColumn dc in dt.Columns) { nCol++; object dcValue = Rowset.GetData(nCol); if (dcValue != null) { if (dc.DataType == typeof(System.String)) dr[dc] = (string)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Int32)) dr[dc] = (int)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Single)) dr[dc] = (float)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.DateTime)) dr[dc] = (DateTime)Rowset.GetData(nCol); } } dt.Rows.Add(dr); Rowset.MoveNext(); } } Also, can I assign a set number of rows to the DataTable before I start and just load without adding new rows. Any help would be greatly appreciated. Thanks in advance. Michael

      S Offline
      S Offline
      Syed Mujtaba Hassan
      wrote on last edited by
      #2

      Is there any exception? If yes then what is the exception message?

      Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

      M 1 Reply Last reply
      0
      • S Syed Mujtaba Hassan

        Is there any exception? If yes then what is the exception message?

        Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

        M Offline
        M Offline
        MAW30
        wrote on last edited by
        #3

        There is no exception message is just continues on to the next table (I am trying to load multiple tables). Michael

        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