Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have an issue regarding execution of Stored procedure.

Actually, I have a stored procedure for databases backup in which I have implemented Cursors for each database to be backed up in that server. For execution of database backup, I have to just pass a parameter in that SP i.e. Folder path in which backup can be taken.

Now, when I pass the folder path from the ASP.Net web page, it takes backup of few databases while running almost for 30-45 secs then it gives error 'Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.'.

Secondly, I execute same procedure from query window of SQL Server passing same file path as parameter, it runs successfully without any error.

Please give me suggestions about this issue.
Posted
Comments
Mantu Singh 7-May-12 8:33am    
Pls post code where you got error.......!
ZurdoDev 7-May-12 8:35am    
How long does it take to run in the query window?
bbirajdar 7-May-12 9:52am    
Use SQL server profiler to check whats happening during execution
Maciej Los 8-May-12 9:05am    
[EDIT]Moved from answer[/EDIT]
Firstly, Thanks to all for valuable suggestions.
Solution is that I have increased SqlCommand CommandTimeOut. Now it's working fine.
Ashish Naval
Maciej Los 8-May-12 9:23am    
Dear Ashish Naval,
A good practice is to mark your question as "solved" and to rate any valuable solutions.

try this :

C#
SqlCommand.Timeout = 1000;


try changing your time out values for your command object depending upon the requirements. But this is not a good idea to rely on timeout. rather change your SP.
 
Share this answer
 
Comments
Herman<T>.Instance 7-May-12 9:56am    
It is indeed the TimeOut that is working against him. If he sets it to 0 it runs forever unless the call is finished.
Maciej Los 8-May-12 9:24am    
Good answer, my 5!
You can set this value in web.config. For example, to change the timeout for one specific page:

HTML
<location path="somefile.aspx">
        <system.web>
                <httpRuntime executionTimeout="180"/>
        </system.web>
</location>


See http://msdn2.microsoft.com/en-us/library/e1f13641.aspx for more details.

Hope that helps.
 
Share this answer
 
Comments
Maciej Los 8-May-12 9:23am    
Good answer, my 5!

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



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