Jesuraja
Jesuraja

Reputation: 3844

SqlConnection.ConnectionTimeout Property

I tried to set ConnectionTimeout of SqlConnection object (C#). But it is read-only property. Default timeout to establish connection is specified as 15 seconds. I want to increase the timeout to 60 seconds.

Is there any other way to set ConnectionTimeout property?

Upvotes: 0

Views: 1345

Answers (2)

nvoigt
nvoigt

Reputation: 77304

You can set the connection timeout in the connection string your pass to the SqlConnection instance.

"Connection Timeout=60"

Upvotes: 2

Dhaval Patel
Dhaval Patel

Reputation: 7601

if it's for one or two query probs then you can set the CommandTimeout property.

cmd.CommandTimeout = Convert.ToInt16(ConfigurationManager.AppSettings["CommandTimeout"].ToString());

Upvotes: 0

Related Questions