tags:

views:

705

answers:

4

i want to set the querytimeout fromt he connection string. not the connection timeout , is it possible?

+3  A: 

No. It's per command, not per connection.

gbn
+1  A: 

See:- ConnectionStrings content on this subject. There is no default command timeout property.

AnthonyWJones
+1  A: 

You can only set the connection timeout on the connection string, the timeout for your query would normally be on the command timeout. (Assuming we are talking .net here, I can't really tell from your question).

However the command timeout has no effect when the command is executed against a context connection (a SqlConnection opened with "context connection=true" in the connection string).

Iain Hoult
thanks guys , its make sense casue the connection string can be used for other queris
A: 

This work for me:

connectionString = "Server=NoExist;Database=tempdb;User ID=sa;Password=12345678;Connection Timeout=2;"

Sasha
That's the connection timeout, not command timeout - very different. Iain's answer from 6 months ago explained the distinction, and the OP explicitly called out the fact that he wasn't looking for the connection timeout.
Aaronaught