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.Row s
Dim MyValue As Integer
If dr("ID").Equals (DBNull.Value) Then
dr.SetColumnErr or("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 1093
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.Col umns.Add(ID)
For i As Integer = 0 To 100
Dim dr = myDataTable.New Row
dr("ID") = DBNull.Value
myDataTable.Row s.Add(dr)
Next
For Each dr As DataRow In myDataTable.Row s
Dim MyValue As Integer
If dr("ID").Equals (DBNull.Value) Then
dr.SetColumnErr or("ID", "ID cannot be null") ' this take
1 to 2 seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
Next
Console.WriteLi ne(a.ElapsedMil liseconds / 1000)
Console.ReadLin e()
End Sub
End Module
///
Cor
"Charles Law" <bl***@nowhere. comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.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.Row s
Dim MyValue As Integer
If dr("ID").Equals (DBNull.Value) Then
dr.SetColumnErr or("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******** *************** ***********@mic rosoft.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.Col umns.Add(ID)
For i As Integer = 0 To 100
Dim dr = myDataTable.New Row
dr("ID") = DBNull.Value
myDataTable.Row s.Add(dr)
Next
For Each dr As DataRow In myDataTable.Row s
Dim MyValue As Integer
If dr("ID").Equals (DBNull.Value) Then
dr.SetColumnErr or("ID", "ID cannot be null") ' this take
1 to 2 seconds each time
Else
MyValue = CType(dr("ID"), Integer)
End If
Next
Console.WriteLi ne(a.ElapsedMil liseconds / 1000)
Console.ReadLin e()
End Sub
End Module
///
Cor
"Charles Law" <bl***@nowhere. comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.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.Row s Dim MyValue As Integer
If dr("ID").Equals (DBNull.Value) Then dr.SetColumnErr or("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.inv alidwrote in message
news:6j******** ****@mid.indivi dual.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********@com cast.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 method would take so long to
execute. I've tried setting the EnumerationOptions.EnumerateDeep to false
but it doesn't seem to have any impact on the time. Can someone tell me how
to speed up the execution of this method?
--
Steve
|
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 categories where the selected product belongs to.
These checked categories are listed in a textbox named "theIDs" (ex:
25,116,420)
In the texbox named "chk_counter" there is the number of selected
categories: in this example: 3
So, in the table, I...
|
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. thanks!
|
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 PC Win2k professional
with IIS5.0
but These report which takes longer duration does not work on the Production
System 2003 server with IIS6.0.
but the log entries that are written at the server states that the process
is completed. but the user...
| |
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.
The queries inside the package, if run seperately, come out in milliseconds in total.
On looking through the sql trace when the package was run, it was found that an insert on a global Temp table is consuming around 5 mins (elapsed = 310 secs). ...
|
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?
any pointers here lads? on other servers the exact same script does it's job
in 3 seconds...but not this one?
???
|
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 this
repsonse if it takes more than, say, 2 seconds to a response from the
webserver.
Basically, how would I immediately end a function that is taking too
long to respond?
--
|
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 it.
Here's my code:
For Each dr As DataRow In MyDataTable.Rows
Dim MyValue As Integer
If dr("ID").Equals(DBNull.Value) Then
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |