Hello. I've read some similar topics (most of them on this forum), but none of them helped.
I have a stored procedure which runs fine on SQL Server (in 0 ms). The problem occurs when i try to run it under a WindowsForm application (C#).
The following codeCode Block
SqlConnection sqlCon = GetConnection();
cmdUpdate = new SqlCommand("StoredProcedure_Name", sqlCon);
cmdUpdate.CommandType = CommandType.StoredProcedure;
cmdUpdate.CommandTimeout = 300;
produces the exception: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." on the ExecuteNonQuery() line.
It's not a problem with the CommandTimeout or the ConnectionTimeout (from within the connection string), they are both set to 300 (and even when set to 0, the problem is the same).
It's very strange, because only two stored procedures don't work, the others work without any problems and under SQL Server (using EXEC stored_procedure) all of them work fine. It seems like the stored procedure is executed, but no response is returned to the client (the WinForm app), thus the timeout exception.
Any ideas? Thanks.
- Dipindahkan oleh Bob BeaucheminMVP 06 Desember 2010 5:08 Moved to a more relevent forum (From:.NET Framework inside SQL Server)
Procedure is effecting the records. they work fine. I'm using ExecuteNonQuery for that. I'm coping data from mdb file to sqlserver table. at there approx. over 60,00,000 recored's.
and one interesting think is that when i set the commandtimeout=0 after that sqlcommand run approx. 1.5 minutes. but after that this working in background after 3 minute if i check all data is copyied in sql table.
this is my code
cmd = new SqlCommand("sp_CallProcedure", conn);
cmd.CommandTimeout = 0;
if (conn.State == ConnectionState.Open)
thnks fo response
ExecuteNonQuery required Open connection. Close it only when the command is finished. As the command needs much time you need to either increase timeout or use BeginExecuteNonQuery which will not time out.
MCTS, CodeProject MVP 2008
- Disarankan sebagai Jawaban oleh Papy Normand 28 April 2012 21:23