G
Guest
I am using Visual Studio 2003 and am getting lousy performance after using
a datatable select and then trying to assign a value to a column of the row
that was found:
DataTable dt = new DataTable();
dt.Columns.Add("Number", System.Type.GetType("System.Int32"));
dt.Columns.Add("Value", System.Type.GetType("System.Double"));
for(int i=0;i<2000;i++)
{
DataRow dr = dt.NewRow();
dr["Number"] = i;
dr["Value"] = 1.0;
dt.Rows.Add(dr);
}
for(int i=0;i<2000;i++)
{
// use the select
string filter = "Number = " + i;
DataRow[] rows = dt.Select(filter);
// assign a new value to the row that was found
if(rows.Length > 0) rows[0]["Value"] = 2;
}
I want to note that this is only if both a select and assign are used
together. Performance is fine if one is used without the other. Anyone
encounter this and know of a workaround?
a datatable select and then trying to assign a value to a column of the row
that was found:
DataTable dt = new DataTable();
dt.Columns.Add("Number", System.Type.GetType("System.Int32"));
dt.Columns.Add("Value", System.Type.GetType("System.Double"));
for(int i=0;i<2000;i++)
{
DataRow dr = dt.NewRow();
dr["Number"] = i;
dr["Value"] = 1.0;
dt.Rows.Add(dr);
}
for(int i=0;i<2000;i++)
{
// use the select
string filter = "Number = " + i;
DataRow[] rows = dt.Select(filter);
// assign a new value to the row that was found
if(rows.Length > 0) rows[0]["Value"] = 2;
}
I want to note that this is only if both a select and assign are used
together. Performance is fine if one is used without the other. Anyone
encounter this and know of a workaround?