G
Gerry Viator
Hi all,
Problem adding the first new row in a datatable, very slow when
it gets to this line "MainSavedDataTable.Rows.Add(myRow)"
see below.
I have a datatable called "MainSavedDataTable" declared in Module
I then call this in a procedure to load Columns, which is no problem
Friend Sub CreateValueTable()
Dim i As Integer
Dim CntColumn As New DataColumn("Count")
CntColumn.DataType = GetType(Integer)
CntColumn.AutoIncrement = True
CntColumn.AutoIncrementSeed = 1
MainSavedDataTable.Columns.Add(CntColumn)
With MainDS.Tables("EntryDataTable")
For i = 0 To .Rows.Count - 1
If .Rows(i).Item("ModuleOwner") = GlobalModuleName Then
Dim StrName As String = .Rows(i).Item("EntryName")
Dim fusename As String = "Col" & StrName
Dim Colname As New DataColumn(StrName)
Colname.DataType = GetType(String)
MainSavedDataTable.Columns.Add(Colname)
End If
Next
End With
'Make datagrid equal datatable
EntryGrid.DataSource = MainSavedDataTable
End Sub
'sEntryName = the correct Column to place the value
'Now add first value to the "sEntryName" Column
Dim myRow As DataRow = MainSavedDataTable.NewRow
ItemValue = txtboxforlist.Text
myRow(sEntryName) = ItemValue
MainSavedDataTable.Rows.Add(myRow)
MessageBox.Show("Value Added")
Again the problem is when I add the first row in the datatable
(MainSavedDataTable.Rows.Add(myRow)), takes 3 - 4 seconds before the
messagebox pops up.
I'm actualy updating a datagrid but, used a messagebox to just help me to
determine where it is slow.
thanks for your help
Gerry
Problem adding the first new row in a datatable, very slow when
it gets to this line "MainSavedDataTable.Rows.Add(myRow)"
see below.
I have a datatable called "MainSavedDataTable" declared in Module
I then call this in a procedure to load Columns, which is no problem
Friend Sub CreateValueTable()
Dim i As Integer
Dim CntColumn As New DataColumn("Count")
CntColumn.DataType = GetType(Integer)
CntColumn.AutoIncrement = True
CntColumn.AutoIncrementSeed = 1
MainSavedDataTable.Columns.Add(CntColumn)
With MainDS.Tables("EntryDataTable")
For i = 0 To .Rows.Count - 1
If .Rows(i).Item("ModuleOwner") = GlobalModuleName Then
Dim StrName As String = .Rows(i).Item("EntryName")
Dim fusename As String = "Col" & StrName
Dim Colname As New DataColumn(StrName)
Colname.DataType = GetType(String)
MainSavedDataTable.Columns.Add(Colname)
End If
Next
End With
'Make datagrid equal datatable
EntryGrid.DataSource = MainSavedDataTable
End Sub
'sEntryName = the correct Column to place the value
'Now add first value to the "sEntryName" Column
Dim myRow As DataRow = MainSavedDataTable.NewRow
ItemValue = txtboxforlist.Text
myRow(sEntryName) = ItemValue
MainSavedDataTable.Rows.Add(myRow)
MessageBox.Show("Value Added")
Again the problem is when I add the first row in the datatable
(MainSavedDataTable.Rows.Add(myRow)), takes 3 - 4 seconds before the
messagebox pops up.
I'm actualy updating a datagrid but, used a messagebox to just help me to
determine where it is slow.
thanks for your help
Gerry