Timeout expired - solve via ConnectionString?

G

Guest

Hello,
I'm building an App that has a large query. I get
"System.Data.SqlClient.SqlException: Timeout expired". I know I can fix this
by increasing the CommandTimeout property of SqlCommand instance. However, I
use the Microsoft Data Application Block v2, and this requires me to modify
that block.

Is there a way to get the same affect by changing just the connection string?

Thanks,
Mark
 
M

Mythran

Mark said:
Hello,
I'm building an App that has a large query. I get
"System.Data.SqlClient.SqlException: Timeout expired". I know I can fix
this
by increasing the CommandTimeout property of SqlCommand instance. However,
I
use the Microsoft Data Application Block v2, and this requires me to
modify
that block.

Is there a way to get the same affect by changing just the connection
string?

Thanks,
Mark

www.connectionstrings.com

Click SQL Server->Read more->All SqlConnection connectionstring properties
and read that for all connection string parameters ;)

The one your looking for is "Connect Timeout" or "Connection Timeout"
property.

Hope that helps :)

Mythran
 
M

Mythran

Mark said:
Hello,
I'm building an App that has a large query. I get
"System.Data.SqlClient.SqlException: Timeout expired". I know I can fix
this
by increasing the CommandTimeout property of SqlCommand instance. However,
I
use the Microsoft Data Application Block v2, and this requires me to
modify
that block.

Is there a way to get the same affect by changing just the connection
string?

Thanks,
Mark

BTW, that's an awesome site for connection strings. VERY extremely
simplistic yet thorough about connection strings.

Mythran
 
G

Guest

Thanks for the email.
I've been to the www.connectionstring.com site, and I've tried using
Connection Timeout = <big number>.

That doesn't affect the issue. It seems like Connection TimeOut is designed
to connect to the database, not process a long query.

Do you know if there's something else that must be done?

Thanks,
Mark
 
M

Mythran

Mark said:
Thanks for the email.
I've been to the www.connectionstring.com site, and I've tried using
Connection Timeout = <big number>.

That doesn't affect the issue. It seems like Connection TimeOut is
designed
to connect to the database, not process a long query.

Do you know if there's something else that must be done?

Thanks,
Mark

:


Hrm, I believe the only thing you can do besides modifying the application
block code itself is to create the connection object, modify the
CommandTimeout property then pass this object into the data access block,
instead of just the connection string (a pain, I know).

Anywho, hope this helps :)

Mythran
 
G

Guest

Hello,
Can you confirm if this is true:
ConnectionTimeOut = maximum time allowed to initially connect to DB (not
total time connected to the database, i.e. ConTO can be less than CmdTO)
CommandTimeout = maximum time allowed to perform a command (such as run a SP)

Therefore for example, you could have ConTO = 30 (set in the connection
string) and CmdTO = 100 (set in the instance of the Command object).

Thanks,
Mark
 
A

Angel Saenz-Badillos[MS]

Consider it confirmed. As Sahil correctly states you can't set the command
timeout from the connection string, sorry.
--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.
I am now blogging about ADO.NET: http://weblogs.asp.net/angelsb/
 
M

Mythran

Sahil Malik said:
ConnectionTimeOut != CommandTimeout.
Also - afaik, you cannot modify commandtimeout using connection string.

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/

Here's a wierd problem...last week I was having a problem with Bulk
Inserting data. I kept getting a timeout error every time it went > 15
seconds (I believe it was 15 sec). Anywho, the fix was to increase the
Connection Timeout in the connection string....that was causing the timeout
error for the bulk insert. Is this a bug because it uses the wrong timeout?

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top