Well thansk Cor, you helped me a lot! In my application, which has a
DataTable with only 2 columns it takes like 50 ticks to merge a DataRow() of
200 records and a DataTable of 12000 records! So really a great performance.
I now have another part that becomes the bottleneck: adding the datatable to
the combobox: It teks easily 850 ticks... any idea to get it better?
Here's my code:
Private Sub AddSearchedToLi st()
Dim dtbl As New DataTable
dtbl = MyWorkSpace.Get AllArticlesClie nt(61).Copy
Dim drows() As DataRow
drows = dtbl.Select("No mArticle LIKE '*HUILE*'", "NomArticle ")
dtbl = Me.InsertDataRo ws(drows, dtbl)
'add to the combo
Dim start As Integer = Environment.Tic kCount
cmbTest.Suspend Layout()
cmbTest.BeginUp date()
Me.cmbTest.Data Source = dtbl 'dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"
cmbTest.EndUpda te()
cmbTest.ResumeL ayout()
MessageBox.Show ((Environment.T ickCount - start).ToString ) '-> +- 850
End Sub
Private Function InsertDataRows( ByVal drows() As DataRow, ByVal dtbl2 As
DataTable) As DataTable
Dim dtbl As New DataTable
Dim dr As DataRow
Dim intX, intY As Integer
Dim start As Integer = Environment.Tic kCount
'For intX = 0 To intColumns
' dtbl.Columns.Ad d()
'Next
dtbl.Columns.Ad d("CodeArticle" )
dtbl.Columns.Ad d("NomArticle ")
dtbl.BeginLoadD ata()
'first dtbl1
For intX = 0 To (drows.Length - 1)
dr = dtbl.NewRow
For intY = 0 To 1
dr(intY) = drows(intX).Ite m(intY)
Next
dtbl.Rows.Add(d r)
Next
'add the lines betweeen the 2 datatables...
dr = dtbl.NewRow
dr(1) = " ------------------------"
dtbl.Rows.Add(d r)
'than dtbl2
For intX = 0 To (dtbl2.Rows.Cou nt - 1)
dr = dtbl.NewRow
For intY = 0 To 1
dr(intY) = dtbl2.Rows(intX ).Item(intY)
Next
dtbl.Rows.Add(d r)
Next
dtbl.EndLoadDat a()
MessageBox.Show ((Environment.T ickCount - start).ToString ) '-> +-50
Return dtbl
End Function
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:OT******** ******@TK2MSFTN GP14.phx.gbl...
Werid, it took only 550-650 ticks each time... That's so much less than
the results I got? I even used DataTable.Begin LoadData and EndLoadData...
I guess I'll have to review some stuff, hehe :) Thanks a lot Cor! You did
that hartstikke good!
Was there any reason why you did that in steps of 100 times 150? I didn't
notice any remarkable changes on first sight when changing these
parameters? Should they?
Thanks,
Pieter
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:u4******** ******@TK2MSFTN GP09.phx.gbl... Pieter,
What is it you use as computer a 'telraam' system.
Can you try this sample and tell me how much milliseconds you was using.
If I did not make an error, than it creates a table with 100 filled
columns and 15000 rows by steps from 100 in a time.
\\\
Public Class Main
Public Shared Sub Main()
Dim start As Integer = Environment.Tic kCount
Dim dt As New DataTable
For i As Integer = 0 To 99
dt.Columns.Add( )
Next
For x As Integer = 1 To 100
For i As Integer = 1 To 150
Dim dr As DataRow = dt.NewRow
For j As Integer = 0 To 99
dr(j) = "Pieter"
Next
dt.Rows.Add(dr)
Next
Next
MessageBox.Show ((Environment.T ickCount - start).ToString )
End Sub
End Class
//
:-)
Cor