CODECUBE VENTURES

Is there a limit on DataTable columns?

Forgot to post this ... a few days ago I responded to a question on the .net newsgroups. The person was asking whether the DataTable class has a limit to how many columns it can house. I whipped up a quick console app to test it and figured I'd post it here in case it helps anyone else out there.

The code adds 10,000 columns to a DataTable so it would seem that there is no limit :-)

DataSet ds = new DataSet();
DataTable tbl = new DataTable();
ds.Tables.Add(tbl);

int i=0;
try
{
for (i=0;i<10000;i++)
{
tbl.Columns.Add(
new DataColumn(i.ToString(),
typeof(int)));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

Latest post: Digging Up the First Version of CodeCube

See more in the archives