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. Maximum number of columns that can be added in a dataset table

Maximum number of columns that can be added in a dataset table

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • K Offline
    K Offline
    kgaurav kumbhawat
    wrote on last edited by
    #1

    I am trying to add around 3000 columns to a dataset table.But it fails to add after a limit. Is there any limitation to number of columns that can be added.If yes then what?

    T M K 3 Replies Last reply
    0
    • K kgaurav kumbhawat

      I am trying to add around 3000 columns to a dataset table.But it fails to add after a limit. Is there any limitation to number of columns that can be added.If yes then what?

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      Dave Kreskowiak wrote[^]:

      If you have to hit that limit, you've got bigger issues with your application... It's System.Int32.MaxValue, or 2,147,483,647. But since you wont be able to reach that limit without generating an OutOfMemory Exception, it's limited by available memory.

      Can't find the max columns in Datatable[^]

      thatraja


      My Dad had a Heart Attack on this day so don't...
      Pompeyboy3 here
      | Nobody remains a virgin, Life screws everyone :sigh:

      1 Reply Last reply
      0
      • K kgaurav kumbhawat

        I am trying to add around 3000 columns to a dataset table.But it fails to add after a limit. Is there any limitation to number of columns that can be added.If yes then what?

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        kgaurav.kumbhawat wrote:

        add around 3000 columns to a dataset table

        I got stuck with one of these requirements a few years ago, needed to export a shed load of stress data and my favourite tool exports a datatable to CSV. I had to rewrite the method to write a CSV directly. You can find the limitations in MSDN but I don't have a link. If you are wanting a database table with 3k columns then take a serious look at your requirements there should be a better solution than 3k of columns!

        Never underestimate the power of human stupidity RAH

        T 1 Reply Last reply
        0
        • M Mycroft Holmes

          kgaurav.kumbhawat wrote:

          add around 3000 columns to a dataset table

          I got stuck with one of these requirements a few years ago, needed to export a shed load of stress data and my favourite tool exports a datatable to CSV. I had to rewrite the method to write a CSV directly. You can find the limitations in MSDN but I don't have a link. If you are wanting a database table with 3k columns then take a serious look at your requirements there should be a better solution than 3k of columns!

          Never underestimate the power of human stupidity RAH

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #4

          Mycroft Holmes wrote:

          You can find the limitations in MSDN but I don't have a link.

          I But there is no details about MAX columns only MAX rows there.

          From MSDN[^]:

          To add rows to a DataTable, you must first use the NewRow method to return a new DataRow object. The NewRow method returns a row with the schema of the DataTable, as it is defined by the table's DataColumnCollection. The maximum number of rows that a DataTable can store is 16,777,216. For more information, see Adding Data to a DataTable.

          thatraja


          My Dad had a Heart Attack on this day so don't...
          Pompeyboy3 here
          | Nobody remains a virgin, Life screws everyone :sigh:

          1 Reply Last reply
          0
          • K kgaurav kumbhawat

            I am trying to add around 3000 columns to a dataset table.But it fails to add after a limit. Is there any limitation to number of columns that can be added.If yes then what?

            K Offline
            K Offline
            Kabwla Phone
            wrote on last edited by
            #5

            The DotNet helpfile does not explicitly state a limit on the number of columns. Some time ago I had the same questions 'how many columns can I add' so I wrote a simpel loop. I was able to add more than 10,000 columns with unique names and of object type, so your 3,000 should be possible. So the question becomes, how is it failing? What is the error message you are getting? Without this information we are just playing a guessing game. So please let us know... Here are a few simple things to check: Are you sure all your columnnames are unique? Are you running out of memory? (How much memory are you consuming when the addition fails.) Do you have any rows in the table already is is the table empty? Thanx. (EDIT: So I was a little slow typing this response, not changing the text though)

            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