D
diesel
After several frustrating hours, I found a solution to a problem that
I've been having with DataTable.Add running very slow when trying to
add a bunch of records. I found similar questions posted but no good
answers, so I thought I'd post this in hopes of helping someone else.
Problem: DataTable.Add is very slow. It may be relatively fast when
the DataTable already has some rows in it, but is terribly slow when
the DataTable is empty.
First, unbind any controls that are bound to the DataTable or dependent
DataViews. For example: myDataGrid.SetDataBinding(Nothing, Nothing).
Next, before you start your batch Add process, call
myDataTable.BeginLoadData(). This turns off notifications that the
DataTable normally does automatically when you Add. After you are done
adding rows, call myDataTable.EndLoadData(). This turns them back on.
myDataGrid.SetDataBinding(Nothing, Nothing)
myDataTable.BeginLoadData()
' Add a bunch of rows here...
myDataTable.EndLoadData()
Good luck.
I've been having with DataTable.Add running very slow when trying to
add a bunch of records. I found similar questions posted but no good
answers, so I thought I'd post this in hopes of helping someone else.
Problem: DataTable.Add is very slow. It may be relatively fast when
the DataTable already has some rows in it, but is terribly slow when
the DataTable is empty.
First, unbind any controls that are bound to the DataTable or dependent
DataViews. For example: myDataGrid.SetDataBinding(Nothing, Nothing).
Next, before you start your batch Add process, call
myDataTable.BeginLoadData(). This turns off notifications that the
DataTable normally does automatically when you Add. After you are done
adding rows, call myDataTable.EndLoadData(). This turns them back on.
myDataGrid.SetDataBinding(Nothing, Nothing)
myDataTable.BeginLoadData()
' Add a bunch of rows here...
myDataTable.EndLoadData()
Good luck.