?
Solved

MSSQL Timeout Issue

Posted on 2011-10-09
7
Medium Priority
?
332 Views
Last Modified: 2012-05-12
Hi There,

I have an issue which i cannot seem to find a solution to. I have a .NET console application that runs at 11pm each night and is scheduled to run on a dedicated Win 2003 server using Scheduled Tasks.

The application makes a connection to a MSSQL database on another Win 2008 server. When I run the application by running the executable (double click on icon) the application runs perfectly. However when it is executed by the scheduled task the System.Data.SqlClient.SqlException is fired alerting me that the Timeout has expired.

If anyone has experienced this or has any ideas on what to do to fix the issue that would be great!

Cheers
John
0
Comment
Question by:pawnit
7 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 36940574
Increase the ConnectionTimeout property of the SqlConnection. You can also specify the ConnectionTimeout in the connection string if prefered.

The default is 15 seconds and might not be sufficient when the application starts in different ways that being started by the user.
0
 
LVL 5

Expert Comment

by:AlokJain0412
ID: 36940710
1. A value of 0 indications no limit, and should be avoided in a CommandTimeout because an attempt to execute a command will wait indefinitely.

2. Either You can check you Connection setting and
connection string property

 Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User  ID=userName; Password=password; Connect Timeout=9999")


You can set the select command's timeout value in SqlDataSource's Selecting
event:

Example :-

protected void SqlDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 30;
}


and See this thread help you
http://geekswithblogs.net/chrishan/archive/2007/07/18/114030.aspx
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36941662
Are you using Windows Authentication on SQL Server? Task scheduler service runs under System Account and your exe would run under the same account when launched by scheduler.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:pawnit
ID: 36941672
CodeCruise, I am using SQL Authentication.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36941750
How long does your query take in management studio to run? Do you have firewalls installed?
0
 
LVL 25

Assisted Solution

by:jogos
jogos earned 1000 total points
ID: 36941848
If you run that at another time is there a problem?
Something what could happen
1. Jobs exactly at 11pm. Most people start 'normal' jobs at exactly the hour, also jobs that run every hour
-> start it at 11pm15 and possible you will not be bothered anymore by other jobs running at 11pm
2. 11pm could be an hour that is problematic because or your Sql is doing maintenance (backup, defrag, reindex .....) or your network is just slow because for example backup-traffic.
0
 

Author Closing Comment

by:pawnit
ID: 36999235
Did a combination of changing the time of the script and the timeout interval and all is working well now
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question