Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have develop winForm application
using
1. vs 2012
2. Sqlserver 2012
3. Devcomp
4. 3 tier architecture
The execution of program were fine but by the time i did more work on my application it's starting time going down and down and down Now it take too much time to start/execute.. and specially show an error timeout in my sql DAL class when i use this code on one of my form. why my winform slow down now?
C#
if (clbBooksName.GetItemChecked(0) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 1";
           }
           if (clbBooksName.GetItemChecked(1) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 2";
           }
           if (clbBooksName.GetItemChecked(2) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 3";
           }
           if (clbBooksName.GetItemChecked(3) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 4";
           }
           if (clbBooksName.GetItemChecked(4) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 5";
           }
           if (clbBooksName.GetItemChecked(5) == true)
           {
               BookSelection = "OR Hadith_Book_Number = 6";
           }
           foreach (DataGridViewRow Datarow in dataGridView1.Rows)
           {
               if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null && Datarow.Cells[3].Value != null)
               {
                   WhereClause += Datarow.Cells[0].Value.ToString() + "= 4";
               }
           }

           SearchQuery = "Select * From Hadiths_old Where Baab_Id < 100 =" + BookSelection + "AND" + WhereClause;
           MessageBox.Show(WhereClause);
Posted
Updated 27-Oct-13 20:35pm
v3
Comments
Sergey Alexandrovich Kryukov 28-Oct-13 2:07am    
How can anyone possibly fix it for you? There can be too many ways to screw up performance... Do be serious...
—SA
Muhamad Faizan Khan 28-Oct-13 2:14am    
what are some??
Sergey Alexandrovich Kryukov 28-Oct-13 3:14am    
How can I know what could it be in your case?
You fragment of code is not related to performance problems but unacceptable anyway...
—SA
Muhamad Faizan Khan 28-Oct-13 3:28am    
fragment of code unacceptable why??
Sergey Alexandrovich Kryukov 28-Oct-13 3:33am    
Because you write 6 nearly identical fragment of code. The whole idea of programming is: D.R.Y.:
http://en.wikipedia.org/wiki/Don%27t_repeat_yourself.
And writing it normally is very easy. Also, you hard-code strings (again, almost identical) using immediate constant. How to explain that? This is not bad programming, this is not programming at all.
—SA

if you are retrieving any database records in application start.
then it ll slow down.
1st check connection is avail or not. if avail then retrieve value.
always use procedure and views to retrieve and insert record.
it makes performance faster.
don't retrieve all records mean to say never use "*" in queries.
always retrieve columns that you need. it makes application faster.

Hope these things help you ..



use column names. not "*"
Contact your Database administrator for help.
as its time out error thrown by sql server.
restart the server and try again.
 
Share this answer
 
v2
win forms is less performance than MVC so try check if you can change it from ASP.net win forms to MVC

OR

you can check your code performance by using tools for performance test and enhance your code make less loops , check the connections between all servers SQL server and Application front end servers
it maybe a connection problem between server if certificate between servers expired (it will authenticate every time application server call SQL server it happens with me)

try to troubleshoot the problem with IT specialists who administer servers , and enhance your code blocks and it will work as charm and do not worry ^-^
 
Share this answer
 

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