473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

What makes this code slow

This code resets a form with two cbo's (comboBoxes) and one datagrid.
The first cbo (cboSelection) selects a main table and filters the
second cbo. The second cbo (cboView) selects the secondary table which
determine the dataAdapter used to fill the dataGrid. Both cbo's are
populated by filling dataAdapters.

This code just empty's the datagrid, cbo's and dataset so the user can
start over to view another set of data.

\\
Private Sub btnResetForm_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnResetForm.Click

'Clear the datagrid
Me.DataGrid1.DataSource = Nothing
Me.DataGrid1.TableStyles.Clear()

'clear the dataset
_dataSet1.Clear()

DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")

'cboSelection
Me.cboSelection.DataSource = _dataSet1
Me.cboSelection.DisplayMember = "tbl010Job.JobNumber"
Me.cboSelection.ValueMember = "tbl010Job.pkJobId"

_bStillLoadingCboSelection = False

_bStillLoadingCboView = True

End Sub
//

What makes this code slow?

It is as slow as if it was about to throw an error.

Or How can I test this code?

Thank you,
dbuchanan

Nov 21 '05 #1
13 2111
Data binding is slow. I'd bet you could
load the combobox faster with your own code.

Did you try trapping errors and see if
one is being generated?

--
Robbe Morris - 2004/2005 Microsoft MVP C#
EggHeadCafe's RSS Search Engine
http://www.eggheadcafe.com/articles/...h/default.aspx


"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
This code resets a form with two cbo's (comboBoxes) and one datagrid.
The first cbo (cboSelection) selects a main table and filters the
second cbo. The second cbo (cboView) selects the secondary table which
determine the dataAdapter used to fill the dataGrid. Both cbo's are
populated by filling dataAdapters.

This code just empty's the datagrid, cbo's and dataset so the user can
start over to view another set of data.

\\
Private Sub btnResetForm_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnResetForm.Click

'Clear the datagrid
Me.DataGrid1.DataSource = Nothing
Me.DataGrid1.TableStyles.Clear()

'clear the dataset
_dataSet1.Clear()

DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")

'cboSelection
Me.cboSelection.DataSource = _dataSet1
Me.cboSelection.DisplayMember = "tbl010Job.JobNumber"
Me.cboSelection.ValueMember = "tbl010Job.pkJobId"

_bStillLoadingCboSelection = False

_bStillLoadingCboView = True

End Sub
//

What makes this code slow?

It is as slow as if it was about to throw an error.

Or How can I test this code?

Thank you,
dbuchanan

Nov 21 '05 #2
Hi Robbe,

Thank you for your reply.

I use the binding all over in my code for comboBoxes and it appears
instantaneous. This block of code is *exceptionally* slloooooowwww!

There is one thing I do a little differently in this block compared to
others but it raised no flags with me for reasons I will explain.

In other code I clear a dataTable with code like this;

'clear the datatable
_dataSet1.tbl040Cmpt.Clear()

but in this block I clear the entire dataset with this code;

'clear the dataset
_dataSet1.Clear()

This has not reaised any flags for me (#1) because there are only a
coulple of tables involved. The reason I clear the dataset instead of
tables is that I don't know which tables it will be - it depends on
user selection.

Another reason (#2) that it has not raised a flag with me is that
subsequaint calls to this block are instantaneous even though the same
numbers of tables are loaded.

Any clues to what might cause this type of behavior?
Did you try trapping errors and see if one is being generated?


I put this block within a try catch block. That did not bring up any
errors. Is there another way to expose errors that I might get me more
results - I'm sort-of new at trapping errors.

Thank you,
dbuchanan

Nov 21 '05 #3
DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")
--
Robbe Morris - 2004/2005 Microsoft MVP C#
Free Source Code for ADO.NET Object Mapper To DataBase Tables And Stored
Procedures
http://www.eggheadcafe.com/articles/..._generator.asp


"dbuchanan" <db*********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
This code resets a form with two cbo's (comboBoxes) and one datagrid.
The first cbo (cboSelection) selects a main table and filters the
second cbo. The second cbo (cboView) selects the secondary table which
determine the dataAdapter used to fill the dataGrid. Both cbo's are
populated by filling dataAdapters.

This code just empty's the datagrid, cbo's and dataset so the user can
start over to view another set of data.

\\
Private Sub btnResetForm_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnResetForm.Click

'Clear the datagrid
Me.DataGrid1.DataSource = Nothing
Me.DataGrid1.TableStyles.Clear()

'clear the dataset
_dataSet1.Clear()

DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")

'cboSelection
Me.cboSelection.DataSource = _dataSet1
Me.cboSelection.DisplayMember = "tbl010Job.JobNumber"
Me.cboSelection.ValueMember = "tbl010Job.pkJobId"

_bStillLoadingCboSelection = False

_bStillLoadingCboView = True

End Sub
//

What makes this code slow?

It is as slow as if it was about to throw an error.

Or How can I test this code?

Thank you,
dbuchanan

Nov 21 '05 #4
Hi Robbe,

The code takes a full five seconds on the first call. It is
instantaneous on each call thereafter.

1.) open the windows form
2.) select the job in the first comboBox
3.) select the view in the second comboBox
.... view the data in the datagrid
4.) Click the Reset button to make another selection
....
....
....
....
.... wait a ful 5 seconds for the form to reset (datagrid and combo
boxes are cleared and reset)
5.) select the job in the first comboBox
6.) select the view in the second comboBox
.... view the data
7.) Click the Reset button
instantaneous reset ready for the user to begin another selection.

Thank you,
dbuchanan

Nov 21 '05 #5
dbuchanan,

Deleting datarows is extremely slow in the version 1.x. This is one of the
points that was especially a point for improvement in 2.0.

I don't know how that affects the clear.

However, why don't you try what creating a new dataset does. The old one
will be automaticly than be deleted by the GC when there is a better time
for that.

I hope this helps,

Cor
Nov 21 '05 #6
Cor, Robbe, Anybody,
Deleting datarows is extremely slow in the version 1.x.


I don't think we're on the right track. - The problem exists only in
this form's clear and only the first time. It is clearing the same
amount of data the second time.

How can I go about detecting what is happening in this code? Or where
exactly the bottleneck is?

Stepping through the code in debug mode is not good enough. It only
shows what I know already... When I step past "_dataSet1.Clear()" the
first time there is a long delay. after populating the form again and
clicking the "reset" button the second time a step past
"_dataSet1.Clear()" is instantaneous. Why? Why does it take so long the
first time? Why is it no problem the second time an all times
thereafter? There *is* a reason! How can I track it down?

Thank you,
dbuchanan

Nov 21 '05 #7
dbuchanan,

Can it be that the dataset is already empty in this case. I thought to
remember me that I have seen that in version 1.x the exception is used to
check that.

That could than explain the situation.

Cor
Nov 21 '05 #8
On 2005-09-18, dbuchanan <db*********@hotmail.com> wrote:
Cor, Robbe, Anybody,
Deleting datarows is extremely slow in the version 1.x.
I don't think we're on the right track. - The problem exists only in
this form's clear and only the first time. It is clearing the same
amount of data the second time.

How can I go about detecting what is happening in this code? Or where
exactly the bottleneck is?


Two thoughts. Attach handlers to the various dataset and datatable
events, to see if you can narrow down exactly where the delay is.

Even more useful probably, go into Debug-Exceptions and set all CLR
exceptions to break into the debugger. This should tell you if
the first Clear is throwing exceptions for some reason.

Also, do you have the same delay if you aren't running in DEBUG mode?
That would be a good sign of exceptions, since exceptions are much, much
slower in a debugger.


Stepping through the code in debug mode is not good enough. It only
shows what I know already... When I step past "_dataSet1.Clear()" the
first time there is a long delay. after populating the form again and
clicking the "reset" button the second time a step past
"_dataSet1.Clear()" is instantaneous. Why? Why does it take so long the
first time? Why is it no problem the second time an all times
thereafter? There *is* a reason! How can I track it down?

Thank you,
dbuchanan

Nov 21 '05 #9
Hi David,

I'm kinda new at this debugging thing...
Attach handlers to the various dataset and datatable events
Could you give me an example of how to do this?
go into Debug-Exceptions and set all CLR exceptions to break into the debugger
Could you explain to me how to navigate to this and what to do when I
get there?
do you have the same delay if you aren't running in DEBUG mode?


The delay in Release mode seems to actually run a little longer than in
DEBUG mode (by about one second).

Thank you,
dbuchanan

Nov 21 '05 #10
On 2005-09-18, dbuchanan <db*********@hotmail.com> wrote:
Hi David,

I'm kinda new at this debugging thing...
Attach handlers to the various dataset and datatable events
Could you give me an example of how to do this?


For each dt As DataTable in MyDataSet
AddHandler dt.RowChanging, AddressOf RowHandler
AddHandler dt.RowChanged, AddressOf RowHandler
.. and so on

Inside the handler, trace some timing information to see if you can
narrow down the problem. Unfortunately some of the handlers have
different signatures, so you'll need to define a few of them. If this
still doesn't make sense, look up AddHandler and Event in the
documentation.
go into Debug-Exceptions and set all CLR exceptions to break into the debugger


Could you explain to me how to navigate to this and what to do when I
get there?


Umm, click the Debug menu, choose the Exceptions options, click on the
CLR Exceptions items, and make sure the "Break Into the Debugger" radio
button is clicked on.

do you have the same delay if you aren't running in DEBUG mode?


The delay in Release mode seems to actually run a little longer than in
DEBUG mode (by about one second).


Then it's probably not exceptions.

Nov 21 '05 #11
dbuchanan wrote:
This code resets a form with two cbo's (comboBoxes) and one datagrid.
The first cbo (cboSelection) selects a main table and filters the
second cbo. The second cbo (cboView) selects the secondary table which
determine the dataAdapter used to fill the dataGrid. Both cbo's are
populated by filling dataAdapters.

This code just empty's the datagrid, cbo's and dataset so the user can
start over to view another set of data.

\\
Private Sub btnResetForm_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnResetForm.Click

'Clear the datagrid
Me.DataGrid1.DataSource = Nothing
Me.DataGrid1.TableStyles.Clear()

'clear the dataset
_dataSet1.Clear()

DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")

'cboSelection
Me.cboSelection.DataSource = _dataSet1
Me.cboSelection.DisplayMember = "tbl010Job.JobNumber"
Me.cboSelection.ValueMember = "tbl010Job.pkJobId"

_bStillLoadingCboSelection = False

_bStillLoadingCboView = True

End Sub
//

What makes this code slow?

It is as slow as if it was about to throw an error.

Or How can I test this code?

Thank you,
dbuchanan


Is there a chance that the query used is slow?
Nov 21 '05 #12
David,

Thank you for your patience at my inexperience.

Following your suggestions I was able to identify the cause of and
elimate two NullReferenceExceptions. I had not disabled the cbo event
while clearing them and I was getting nullreferences on their
selectedValueChanged event. I changed to AddHandler/RemoveHandler to
control this event rather than using conditionals. There is still a
delay, but it is a little shorter. It no longer occurs at the dataset
clear statement.

The delay is no less of a mystery!
Using Debug-Exceptions set to break into the debugger with CLR
exception as you suggested, I get a System.ArgumentOutOfRangeException
for each call to fill using the dataAdapter;

DAL.da010JobFrm.Fill(_dataSet1, "tbl010Job")
DAL.da002ViewList.Fill(_dataSet1, "lst002ViewList")

The myster here is that both these statemetns filled the dataset tables
moments ago with no errors prior to executing the reset button. And
what does ArgumentOutOfRange mean when filling a dataSet?

What would cause such strange behavior?

Thank you,
dbuchanan

Nov 21 '05 #13
Thank you for your reply,

I don't think so for these reasons;
· The query is very simple
· Under other circumstances it runs instantaneous.
· Issues other than the query seem to be emerging

dbuchanan

Nov 21 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Jason | last post by:
Hey, I'm an experience programmer but new to Python. I'm doing a simple implementation of a field morphing techinique due to Beier and Neely (1992) and I have the simple case working in Python...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
17
by: ilPostino | last post by:
Hey, My experience with c++ is limited to ATL and for the past 3 years it's just been c#. I need to write a UI intensive application that is just too slow in managed code. So I'm re-doing it in...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
15
by: jim | last post by:
Maybe I'm missing something, but it doesn't look like Microsoft writes a lot of apps in .Net (although they certainly push it for others). What does MS write using pure .Net? If applications...
184
by: jim | last post by:
In a thread about wrapping .Net applications using Thinstall and Xenocode, it was pointed out that there may be better programming languages/IDEs to use for the purpose of creating standalone,...
20
by: mc | last post by:
I may be opening a can of worms and don't want to start a religious war, but... What features of Java do Java programmers miss when working in C#? Other than, of course, great portability. C#...
6
by: Juha Nieminen | last post by:
I tested the speed of a simple program like this: //------------------------------------------------------------ #include <list> #include <boost/pool/pool_alloc.hpp> int main() { typedef...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.