C# .NET - error while exec stored procedure - Asked By sivakumar subramaniam on 13-Sep-08 02:43 AM

Hai friends,

i have exec the stored procedure am getting timeout expired error.
but i added the sqlcmd.Commantimeout=120;
even am getting the same problem..
can any one me the solution
thnks and advance

Error while exec stored proc - Shailendrasinh Parmar replied to sivakumar subramaniam on 13-Sep-08 02:49 AM

Hi,

The default timeout is 30s... You may try:

1. Plus "Timeout=XX" in your connection string, where XX is seconds
2. Set both Connection.ConnectionTimeout and Command.ConnectionTimeout

Hope this helps.

error while exec stored procedure - Sagar P replied to sivakumar subramaniam on 13-Sep-08 03:05 AM

You need to set the "CommandTimeout" parameter before you open the connection.

change the
Lock_TimeOut in the remote stored procedure.

SET LOCK_TIMEOUT 3000 --3 seconds

May be this will solve your error.

Best Luck!!!!!!!!!!!!!!!!!!
Sujit.

thanks sujit - sivakumar subramaniam replied to Sagar P on 13-Sep-08 03:25 AM

Now is working properly...
Getting timeout expired - Binny ch replied to sivakumar subramaniam on 13-Sep-08 04:36 AM
1) You can not set ConnectionTimeout in code, it mus be done in the connection string (Connect Timeout =30).

2) To modify the command timeout set the CommandTimeout property:
SqlCommand command = new SqlCommand ("myLoadProc", myConnection);
command.CommandTimeout = 180; //3 minutes
.
.
.
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@param1", this.Param ) );
adapter.SelectCommand = command;
adapter.Fill( ds );

command.ResetCommandTimeout();

3) It seems, from the writings, that is a good idea to reset the colmmand timeout after finishing the command to the default . . .

easiest way - Perry replied to sivakumar subramaniam on 14-Sep-08 04:13 AM

Hi,

just set the command timeout parameter before you open any connection by using SQL command like SqlCommand command = new SqlCommand (); and set
command.CommandTimeout = 180;  and other variables like load profiles and connections to the server. This will solve your problem.

-Paresh