I have a data table with ~1000 rows. I go through the rows one at a time,
checking the contents. If I find a cell with an error, e.g containing null,
I use SetColumnError on the data row to flag it.
Here's my code:
For Each dr As DataRow In MyDataTable.Rows
Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then
dr.SetColumnError("ID", "ID cannot be null") ' this take 1 to 2
seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
...
Next
The problem is each call to SetColumnError takes about 1-2 seconds to
execute. This is an ice-age, and if I have 100 cells to flag it takes 100
seconds to go through the data.
Does anyone know why it takes so long for this method to execute?
I am using VS2008 SP1 on XP SP3. I am targeting V3.5 of the framework,
although I have V3.5 SP1 installed. This was a problem before I installed
SP1 though. The back-end is SQL Server 2005, but the data are disconnected,
so I can't see that being an issue.
TIA
Charles 6 2083
Hi Charles,
Takes in Brittain a second the same time as at the continent?
:-)
\\\
Module Module1
Sub Main()
Dim a As New Stopwatch
a.Start()
Dim myDataTable As New DataTable
Dim ID As New DataColumn("ID")
myDataTable.Columns.Add(ID)
For i As Integer = 0 To 100
Dim dr = myDataTable.NewRow
dr("ID") = DBNull.Value
myDataTable.Rows.Add(dr)
Next
For Each dr As DataRow In myDataTable.Rows
Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then
dr.SetColumnError("ID", "ID cannot be null") ' this take
1 to 2 seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
Next
Console.WriteLine(a.ElapsedMilliseconds / 1000)
Console.ReadLine()
End Sub
End Module
///
Cor
"Charles Law" <bl***@nowhere.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I have a data table with ~1000 rows. I go through the rows one at a time, checking the contents. If I find a cell with an error, e.g containing null, I use SetColumnError on the data row to flag it.
Here's my code:
For Each dr As DataRow In MyDataTable.Rows
Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then
dr.SetColumnError("ID", "ID cannot be null") ' this take 1 to 2
seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
...
Next
The problem is each call to SetColumnError takes about 1-2 seconds to
execute. This is an ice-age, and if I have 100 cells to flag it takes 100
seconds to go through the data.
Does anyone know why it takes so long for this method to execute?
I am using VS2008 SP1 on XP SP3. I am targeting V3.5 of the framework,
although I have V3.5 SP1 installed. This was a problem before I installed
SP1 though. The back-end is SQL Server 2005, but the data are
disconnected, so I can't see that being an issue.
TIA
Charles
Hi Cor
Good to hear from you. I tried your test, and it takes only a fraction of a
second, so there is obviously something about my data table that is causing
the problem.
I've just had another thought: I am using the data table as the data source
for a grid. I wonder if the fact that the grid is bound to the data table is
what is making it so slow. I'll have to look into that.
Cheers
Charles
"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:1F**********************************@microsof t.com...
Hi Charles,
Takes in Brittain a second the same time as at the continent?
:-)
\\\
Module Module1
Sub Main()
Dim a As New Stopwatch
a.Start()
Dim myDataTable As New DataTable
Dim ID As New DataColumn("ID")
myDataTable.Columns.Add(ID)
For i As Integer = 0 To 100
Dim dr = myDataTable.NewRow
dr("ID") = DBNull.Value
myDataTable.Rows.Add(dr)
Next
For Each dr As DataRow In myDataTable.Rows
Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then
dr.SetColumnError("ID", "ID cannot be null") ' this take
1 to 2 seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
Next
Console.WriteLine(a.ElapsedMilliseconds / 1000)
Console.ReadLine()
End Sub
End Module
///
Cor
"Charles Law" <bl***@nowhere.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I have a data table with ~1000 rows. I go through the rows one at a time, checking the contents. If I find a cell with an error, e.g containing null, I use SetColumnError on the data row to flag it.
Here's my code:
For Each dr As DataRow In MyDataTable.Rows Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then dr.SetColumnError("ID", "ID cannot be null") ' this take 1 to 2 seconds each time Else MyValue = CType(dr("ID"), Integer) End If
... Next
The problem is each call to SetColumnError takes about 1-2 seconds to execute. This is an ice-age, and if I have 100 cells to flag it takes 100 seconds to go through the data.
Does anyone know why it takes so long for this method to execute?
I am using VS2008 SP1 on XP SP3. I am targeting V3.5 of the framework, although I have V3.5 SP1 installed. This was a problem before I installed SP1 though. The back-end is SQL Server 2005, but the data are disconnected, so I can't see that being an issue.
TIA
Charles
Charles Law wrote:
Good to hear from you. I tried your test, and it takes only a
fraction of a second, so there is obviously something about my data
table that is causing the problem.
I've just had another thought: I am using the data table as the data
source for a grid. I wonder if the fact that the grid is bound to the
data table is what is making it so slow. I'll have to look into that.
Maybe .SuspendLayout and .ResumeLayout on the grid would help?
Andrew
Hi Andrew
I did try that and it didn't improve things. It seems that it is the fact
that the data table is the data source for the grid. I set the data source
to Nothing and the SetColumnError takes a fraction of a second. So, I create
a copy of my data table to work on and then use the copy as the data source
at the end. I couldn't really think of a better way.
Cheers
Charles
"Andrew Morton" <ak*@in-press.co.uk.invalidwrote in message
news:6j************@mid.individual.net...
Charles Law wrote:
>Good to hear from you. I tried your test, and it takes only a fraction of a second, so there is obviously something about my data table that is causing the problem.
I've just had another thought: I am using the data table as the data source for a grid. I wonder if the fact that the grid is bound to the data table is what is making it so slow. I'll have to look into that.
Maybe .SuspendLayout and .ResumeLayout on the grid would help?
Andrew
Charles Law wrote:
Hi Andrew
I did try that and it didn't improve things. It seems that it is the
fact that the data table is the data source for the grid. I set the
data source to Nothing and the SetColumnError takes a fraction of a
second. So, I create a copy of my data table to work on and then use
the copy as the data source at the end. I couldn't really think of a
better way.
Cheers
Charles
Instead of SuspendLayout on the grid control, which really only effects the
positioning on the form, you might try BeginLoadData and EndLoadData on the data
table. This should turn off notifications during your modifications, which might
cut down on all the grid updating until you are done.
Rather than makiing a copy, I would also consider just setting the grid
datasource to nothing, modifying the table, and then reassigning it as the
datasource.
Hi Steve
I tried the Nothing thing before, which did work, but decided to make a copy
instead to avoid the grid going blank during the process, but I appreciate
it will take longer when the data table has many rows.
I will try the BeginDataLoad though; that sounds like it could work.
Cheers
Charles
"Steve Gerrard" <my********@comcast.netwrote in message
news:Zp******************************@comcast.com. ..
Charles Law wrote:
>Hi Andrew
I did try that and it didn't improve things. It seems that it is the fact that the data table is the data source for the grid. I set the data source to Nothing and the SetColumnError takes a fraction of a second. So, I create a copy of my data table to work on and then use the copy as the data source at the end. I couldn't really think of a better way. Cheers
Charles
Instead of SuspendLayout on the grid control, which really only effects
the positioning on the form, you might try BeginLoadData and EndLoadData
on the data table. This should turn off notifications during your
modifications, which might cut down on all the grid updating until you are
done.
Rather than makiing a copy, I would also consider just setting the grid
datasource to nothing, modifying the table, and then reassigning it as the
datasource.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: serge calderara |
last post by:
Dear all,
I have a simple class in my application whcih create
dynamically textbox control to be place on a form
When I execute the code :
log(time)
my control = new myclass()
log (time)
|
by: Steve Teeples |
last post by:
I am calling the method GetInstances() within the ManagementClass. I have 48
applications on my system. Mearly calling the routine takes 28 seconds for
it to return. I don't understand why this...
|
by: nicholas |
last post by:
I have a page that changes some data in an sql-server database: it inserts
the categories for a selected product.
The user checks some categories in a tree (with checkboxes).
These are the...
|
by: Brian Henry |
last post by:
I want to time how long a specific sub takes to execute, what is the best
way to do this? this is only for one sub, and i just need a result back in
milliseconds or such to display to a user....
|
by: prashanth |
last post by:
we have a Asp.net application which is used to generate the reports.
In this application there are some reports which takes more than 50 minutes
of the time.these reports works fine on development...
|
by: vpai |
last post by:
We have a package in production which has suddenly started consuming greater than normal time to execute. On debugging this further, we found the following:
The package takes 5 mins to come out. ...
|
by: =?Utf-8?B?SlZSdWRuaWNr?= |
last post by:
Hey all...
running w2k3/iis6 and trying to shorten the length of time that a simple 10
field ASP form takes to execute using CDOSYS. it takes about 50 seconds each
time...and I've no idea why?
...
|
by: jr |
last post by:
I have an application the makes a call to a webservice to retrieve some
additional info for my app. The information I get back is
non-essential, so I do NOT want my entire app hanging to wait for...
|
by: Charles Law |
last post by:
I have a data table with ~1000 rows. I go through the rows one at a time,
checking the contents. If I find a cell with an error, e.g containing null,
I use SetColumnError on the data row to flag...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |