Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a select query to fill a dataset, that takes tiimes to execute and gives Timeout exception. how to exceed connection timeout limit.

Timeout :-
Quote:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

below is the code :-
try
            {

                string strQry = "select distinct invoice_date,(select sum(amount) from sold_items B where B.invoice_date = A.invoice_date and B.pay_mode=A.pay_mode and tax_percent = '00.00') as taxFree,(select sum(amount) from sold_items C where C.invoice_date = A.invoice_date and C.pay_mode=A.pay_mode and tax_percent =  '5.00') as amountSub5,(select sum(amount) from sold_items D where D.invoice_date = A.invoice_date and D.pay_mode=A.pay_mode and tax_percent =  '14.00') as amountSub14,pay_mode from sold_items A where invoice_date between '" + dtfrom + "' and '" + dtto + "'";
                               
                MySqlDataAdapter da = new MySqlDataAdapter(strQry, con);
                DataSet2 ds1 = new DataSet2();
                da.Fill(ds1, "saletaxreport");
                CRsaletaxreport pr = new CRsaletaxreport();
                pr.SetDataSource(ds1);
                pr.VerifyDatabase();
                crystalReportViewer1.ReportSource = pr;
            }
            catch (Exception ex)
            {
                throw ex;
            }


need your assistance. please help me out.
Posted

1 solution

Hi MERAZ_UDDIN,

Increase the Command Timeout property and you'll be fine with that. See the example below:

----------------------------------------------
da.SelectCommand.CommandTimeout = 600; //or as long you want.
----------------------------------------------

HTH :)
 
Share this answer
 
Comments
[no name] 9-Oct-13 2:52am    
Thanks dear, Its Working.
Sunny_Kumar_ 9-Oct-13 3:07am    
I'm glad it helped :)
[no name] 1-Nov-13 4:53am    
thanks!

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