Once in a while my code encounters
System.Data.SqlClient.SqlException
The service has encountered an error processing your request. Please try again.
Error code 40540. A severe error occurred on the current command.
The results, if any, should be discarded.
Class 20
Number 40197
that happens very rarely, usually goes away in a minute or two and I can't reliably reproduce it. Sometimes Error code
can be a number other than 40540
.
I've Googled a bit and looks like it's usually triggered by bugs in SQL Server and is reproducible.
I have two options - retry the query or treat it as fatal and break hard. I'd prefer to have better understanding what the problem actually is and whether I'm safe retrying the query.
Do I retry the query when this error occurs?
A quick google search gave me this.
You can visit here for more information. It says Your application should catch 40540 and try reconnecting to SQL Database until the resources are available and your connection is established again.
Though on a personal note I would suggest not to use Sql azure as it throttles easily and you can't control the resources allocated to you. What I did was to install sql server on azure vm and use that in my application.
Hope this helps you.
I encountered similar error: And I followed the answer in http://social.msdn.microsoft.com/Forums/en-US/bbe589f8-e0eb-402e-b374-dbc74a089afc/severe-error-in-current-command-during-datareaderread which resolved the issue..
Avoid
looping
of reader; load data in aDataTable