Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have several tabs that load some data on datagrid, the 1st tab works fine, but the 6 others cause my program to freeze. How can i fix it?
This is the code i have for tabcontrol_selectedindexchanged propriety


Code:

[C#] Code - Pastebin.com[^]

What I have tried:

Tried to restructure all the code, from ground 0 with no success...
Posted
Updated 1-Mar-16 17:26pm
Comments
ZurdoDev 1-Mar-16 12:15pm    
If you are timing out make sure you aren't locking the tables. And find a way to create indexes or something to make it faster.
Scribling Doodle 1-Mar-16 12:26pm    
What do you mean by "locking the tables"?
ZurdoDev 1-Mar-16 12:49pm    
I don't know MySql well enough to tell you specifics but when you select data, a lock is put on the data. Sometimes it's just a row lock or it could be a table lock. I suggest reading up on it.

1 solution

Scribling doodle is right in the sense that, it is most important that you prevent the timeout rather than working out how to absorb it.

Having said that, if you are unable to prevent the timeouts from occurring, you should attempt to do the following:

1. Put the code that fetches the data into a thread, so if it times out, it will timeout the thread not your main form, this will make sure that your application remains responsive.
2. Handle exceptions. If you're getting a timeout exception, handle it, e.g. give the opportunity for the user to retry or cancel.
 
Share this answer
 
Comments
Scribling Doodle 2-Mar-16 3:38am    
i keep gettng timeout exceptions because my main tables have 250k+ rows, which can cause some troubles. I'll give a try about threads
[no name] 2-Mar-16 3:53am    
Why are you fetching 250k records, is this really need of that. Secondly you can use indexing on the columns which you are using fro filtering purpose.
Scribling Doodle 2-Mar-16 4:04am    
im creating a parking lot system that requires much data, to know who entered and who left, per day my parking lot has arround 10k+ users joining and leaving. this is the data from the 1st day i began this project, since 2011 or so.

I want my employees to be able to track every car that was here and still is, thats why requesting 250k+ values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900