Wrox Programmer Forums
|
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2010, 02:10 AM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default Connection timeout

my connection is:

Code:
<add name="AdNetConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=AdNet;Integrated Security=True" providerName="System.Data.SqlClient"  />
the error is

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

and I try to add the proberty
Code:
ConnectionTimeout=200
to my connection but this error occurred

The Connection Timeout attribute is not declared.


so please guide me to solve this problem.
 
Old May 31st, 2010, 03:33 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You can add connection timeout to SQL query as follows:

SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();

cmd.Connection.ConnectionTimeout = 30;
cmd.CommandTimeout = 45;

and see if this solves the timeout issue.
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
 
Old May 31st, 2010, 03:37 PM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default

OK,
but this error occurred
Compiler Error Message: CS0200: Property or indexer 'System.Data.Common.DbConnection.ConnectionTimeout '
cannot be assigned to -- it is read only





Similar Threads
Thread Thread Starter Forum Replies Last Post
Abort connection after timeout muklee Javascript How-To 0 June 17th, 2009 06:35 AM
Timeout when connection to SQL Server in WiFi LAN smp4774 SQL Server 2000 1 June 29th, 2007 07:15 AM
Connection pooling and Timeout Raghavendra_Mudugal SQL Server 2000 2 May 24th, 2006 01:42 AM
connection timeout apek PHP How-To 1 February 2nd, 2004 04:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.