0

While i am executing stored procedure via asp.net, application throws connect timeout expire exception. But if i execute stored procedure through query window it executes successfully in 46 seconds.

Do you have any idea about the problem?

daryal
  • 14,643
  • 4
  • 38
  • 54
Vinay
  • 179
  • 2
  • 2

4 Answers4

1

You can set timeout value in the connection string, but to set timeout value for specific stored procedure to be executed, you can use the way suggested by @doterob

Check following links:

Connection Timeout

Command Timeout

Edit:

You might want to check out why it takes so much time to execute the stored procedure.

Nilesh Thakkar
  • 2,877
  • 1
  • 24
  • 43
  • The default timeout if not supplied is 30 seconds, this would explain why your ASP.NET site is timing out, if the query takes 46 seconds. – DaveRead Mar 11 '13 at 11:26
0

The execution produces a timeout exception. You may change the timeout parameter

When you create de SqlCommand to execute stored procedure, you can put the timeout in seconds

SqlCommand command = new SqlCommand();
command.CommandTimeout = 100; //100 seconds
doterob
  • 94
  • 5
0

use this piece of code for checking How much time it is taking

 SqlCommand cmd = new SqlCommand();
 cmd.CommandTimeout = 100;(100 is in second)

by increasing CommandTimeout you can check.

minakshi
  • 315
  • 1
  • 3
  • 17
0

It may be either your sql command execution times out or your web server times out. Since you said it takes 46 seconds in SSMS, I think it is your web server timing out. I would suggest you to increase both time out values to suitable values.

For IIS you could use IIS Manager to do that. Here is a good link for IIS 7.0

Community
  • 1
  • 1
Kaf
  • 33,101
  • 7
  • 58
  • 78