Home  /  Questions  /  Question

85   96.4
Dec 24, 2012

How to use a timeout with SQL database connections.

1. How to use timeout in sql connection / sql data access

2. How to use timeout in method A call method B sync?

3. How to use timeout in method A call method B Async?

85   96.4
Dec 25, 2012
Everyone, who can help me? especially the question 2 & 3.

Jan 05, 2013

you don't need to change the data access.

You can modify your connection string to include a timeout value:

"Data Source=144681;Initial Catalog=Customer;Timeout=60;Persist Security Info=True;User ID=xxxxx;Password=yyyyy"

Set this connection string in Hosting layout->Web.config file:

     <add name="ADO.NET.SqlServer" connectionString=" [your connection string with timeout ] "/>

I'm not sure what is your mean of 2 & 3 but i guess BeginExecute and EndExecute Methods in SqlCommand object can help you.