Hi Matthew,
Thank you for posting in the community!
I will help you on this issue again:-)
I have tested your code, on my machine, it costs over 30 seconds :-(
Actually, I still did not find a good way to greatly improve the
performance of your issue. The only workaround I can think of is first
generate the schema and write it to the disk. Then, when you want to use it
at runtime, just load the schema dynamicly. Like this:
private void button1_Click(o bject sender, System.EventArg s e)
{
DataTable myDataTable=new DataTable();
DataColumn[] adcCols = new DataColumn[3000];
for (int i=0; i<adcCols.Lengt h; i++)
{
adcCols[i] = new DataColumn();
}
myDataTable.Col umns.AddRange(a dcCols);
DataSet ds=new DataSet();
ds.Tables.Add(m yDataTable);
ds.WriteXmlSche ma(@"C:\test.xm l");
MessageBox.Show ("succeed");
}
private void button2_Click(o bject sender, System.EventArg s e)
{
DateTime dt=DateTime.Now ;
DataSet ds=new DataSet();
ds.ReadXmlSchem a(@"C:\test.xml ");
TimeSpan ts=DateTime.Now- dt;
Console.WriteLi ne(ts.Seconds.T oString());
}
This workaround can improve a little performance on your issue.
Actually I think your design of adding so many columns to a datatable is
not a good one. Can you show the community why you want to add so many
columns to a datatable?
=============== =============== ===
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.