Click here to Skip to main content
15,743,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
While executing stored procedure from sql server then it takes less than 3 sec to execute. but when i exceute it from code then it gives Time out expired error - Sql Exception..

Please provide me any solution....

i have searched a lot but didn't find any best solution. i found somewhere to increase timeout period of sql command..i did it but it slows down the exceution of stored procedure from code.... but my query is even fast at sql server end.
deepakaitr12345 22-Jul-14 2:17am    
Hi @Gaurav

I think this is the common problem with the code that is,Connection is not properly closed,
My suggestion over here is dispose or close the connection check the sp_lock command on the sql server when you exicute the Sp and find the locking object which cause exclusive lock.

or Remove connection oriented object.
Hope this help you
krishnaMurali 22-Jul-14 3:13am    
try above suggestion or.. can you provide the method code, in which you are calling SP
Gaurav Gupta A Tech Guy 24-Jul-14 2:10am    
i am using Microsoft.Practices.EnterpriseLibrary.Data library for database connection...and it automatically open and close db connection... so what should i do now....

1 solution

Try to use the CommandTimeout = 0 in your query, if you are using SqlHelper then you need to replace that with the ADO.Net objects.
Share this answer
Gaurav Gupta A Tech Guy 24-Jul-14 2:11am    
i am using Microsoft.Practices.EnterpriseLibrary.Data library for database what should i do now....
Kumarbs 24-Jul-14 2:30am    
I understand that you are using DbCommand class to establish the connections and execute the commands, if so, for that also you can make the DbCommand.CommandTimeOut = 0 so that the process will wait until you get the records. If you are using "Using" class for execution of procudre or query, try to remove that as it has some problems in closing the connections as per my understanding. Let me know if it solves your pblm.
Gaurav Gupta A Tech Guy 28-Jul-14 6:22am    
Yes....i got it.....i will try this. i will inform you if get succussfull......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900