The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Timeout on a (sql) database: SqlConnection.ConnectionTimeOut and SqlCommand.CommandTimeOut.

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
Timeout on a (sql) database: SqlConnection.ConnectionTimeOut and SqlCommand.CommandTimeOut. Posted: Mar 20, 2006 6:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter van Ooijen.
Original Post: Timeout on a (sql) database: SqlConnection.ConnectionTimeOut and SqlCommand.CommandTimeOut.
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement

When your app runs into a timeout on a database operation the error message may lead you in a wrong direction to fix things. Which happened to me so this is my little index to the docs.

A sqlConnection has a ConnectionTimeout property. It  is a property which determines the maximum number of seconds your code will wait for a connection to the database to open. It is set in the connectionstring to the database

data source=BROCHIS;initial catalog=Indato;integrated security=SSPI;Connect Timeout=60;

Opening the connection does not do anything in the database yet. That is handled by a SqlCommand, which could be part of a SqlDataAdapter. The SqlCommand has a CommandTimeOut. This is a settable property which determines the maximum number of seconds the command is given to execute the sql. By default this is 30 seconds. When you perform something costly in the database this is the one whose value you'll have to change.

SqlCommand cmd;

.....

if (bigJob)

   cmd.CommandTimeout = 60;

For both properties a value of 0 indicates to wait forever. Both properties also apply to non sqlserver database operations. They are defined in IdbConnection and IdbCommand.

Read: Timeout on a (sql) database: SqlConnection.ConnectionTimeOut and SqlCommand.CommandTimeOut.

Topic: Migrating to 2007 Office SharePoint Server Previous Topic   Next Topic Topic: Grady Booch on ESBs - sounds familiar

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use