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