Thursday, March 8, 2012

A severe error occurred on the current command. The results, if any, should be discarded.

Hi,

I am hosting my ASP.NET application on a Host and after some time I get this error
(Don't get it on my development machine):

A severe error occurred on the current command. The results, if any, should be discarded.

And then it says this on the same page:

Exception Details: System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

[SqlException: A severe error occurred on the current command. The results, if any, should be discarded.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +9
ASPNetPortal.PortalSettings..ctor(Int32 tabIndex, Int32 tabId)
ASPNetPortal.Global.Application_BeginRequest(Object sender, EventArgs e)
System.Web.SyncEventExecutionStep.Execute() +60
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I thought this is a problem with max pool size and I did it max pool size = 5000, now application runs ok for some time and then produces this error but some times this comes very soon.

As a solution, I have to copy my dll in bin directory again and application restarts and works properly but then after some time this happenes again.

Please let me know whats the problem.
I checked all of my SqlDataReaders and SqlConnections are closed properly.

Any help would be appreciated.

Thanks.

Rahul.Rahul,

Getting a similar problem. I've narrowed it down to 3 stored procedures I wrote, others work fine. In the win2k server event view you should see a message

Error: 17805, Severity: 18, State: 3
2002-09-05 10:39:41.68 ods Invalid buffer received from client.

I've noticed that the StroProc often hangs when using the 'run stored procedure' function in the Explorer window in the V NET IDE. However the data still gets added. This would suggest the StorProc isn't returning a result to the code in time.

Like you our test server is fine. This runs SQL Server 2000 Developer Edition (SP1)

The production server runs SQL Server 7.0 (SP4)

Do your StroProcs use char or varchar types with a 50+ size or have a large number of parameters?

Regards

Richard|||Hi Richard,

Thanks a lot for your support.
Well! Certainly I am using varchar for 50+ size.

But I think I figured out the problem (still not sure) because since last two days I didn't get this error message, for this success I made some changes to my code.

If you think to discuss these changes would be worth then please let me know.

Thanks a lot again.

Rahul.|||So, did anyone ever figure the answer to this problem? I'm having the same issue, development server works fine (SQL2K), production server craps out (SQL7) with errors "Invalid Buffer received from client"|||If anyone's tracking this thread, here's an update: I moved the database to another production server running SQL2000, and it runs flawlessly. So the root cause is something in the way SQL7 handles SP's from .Net. More updates to come as I find them...|||We are having the same problem (with tables in our .NET Forums database) and found this info on a microsoft newsgroup)
Unfortunately the stricter datatype processing is a side effect of the 031
patch. We're working on a KB article to explain the behavior and scope.
Here is a draft of our work in progress:

KB 827366 – “Error 17805: Invalid Buffer Received from Client? Error
Message in SQL”

-----------------------
--

The information in this article applies to:

- Microsoft .NET Framework 1.0 (Version: 1.0)

- Microsoft .NET Framework 1.1

-----------------------
--

SYMPTOMS

========

When you use the SqlClient .NET Framework classes, the following error
messages may appear in the SQL Server 2000 error log:

Error: 17805, Severity: 20, State: 3

Invalid buffer received from client.

The following corresponding errors may appear in the client .NET
application:

System.Data.SqlClient.SqlException: A severe error occurred on
the current command. The results, if any, should be discarded

-or-

System.Data.SqlClient.SqlException: Procedure or function
spXXXX has too many arguments specified.

Note If you are using the .NET Framework 1.1 you only see the last error
message.

CAUSE

=====

There are three causes for these errors:

- You use SqlClient classes in a Finalize method or C# destructor. Do not
use any managed classes in a Finalize method or C# destructor.

- You do not specify an explicit SQLDbType for the parameters. In this
case, the SqlClient .NET provider tries to select the correct SQLDbType
based on the data that is passed and it will fail.

- If the size of the parameter that is specified explicitly in the .NET
code is more than the maximum allowable size for the data type in the SQL
Server.

- For example: According to SQL Server Books Online, nvarchar is a
Variable-length Unicode character data of n characters. n must be a value
from 1 through 4,000 If you specify a size that is more than 4000 for an
nvarchar parameter, then you will receive the error message that the
"Symptoms" section describes.

The following code also demonstrates how these errors can occur:

Stored Procedure

--------

PROCEDURE spParameterBug @.myText Text AS

Insert Into ParameterBugTable (TextField) Values
(@.myText)

Code

---

static void Main(string[] args)

{

string dummyText=string.Empty;

for (int n=0; n < /*80*/ 3277; n++) // change this to
80 to get the second error above

{

dummyText += "0123456789";

}

// TO DO: Change data source to match your SQL Server:

SqlConnection con= new SqlConnection("data
source=myserver;Initial Catalog=mydb;Integrated Security=SSPI;persist
security info=True;packet size=16384");

SqlCommand cmd = new SqlCommand("SpParameterBug", con);

// Correct invocation:

SqlParameter param =new SqlParameter("@.myText",
SqlDbType.Text);

param.Value = dummyText;

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(param);

con.Open();

try

{

cmd.ExecuteNonQuery();

}

catch (Exception err)

{

Console.WriteLine(err.ToString());

}

// Causes error 17805:

SqlParameter param2 =new SqlParameter("@.myText",
dummyText);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add(param2);

try

{

cmd.ExecuteNonQuery();

}

catch (Exception err)

{

Console.WriteLine(err.ToString());

}

Console.ReadLine();

}

RESOLUTION

==========

To resolve these errors, make sure that you do the following:

1. Do not use SqlClient classes in a Finalize method or a C# destructor.

2. Specify the SqlDbType for the SqlParameter so that there is no inferred
type.

3. Specify a parameter size that is within the allowable limits of the data
type.

REFERENCES

==========

For more information about the maximum size for different data types, see
these sections of SQL Books Online:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
na-nop_9msy.asp: nchar and nvarchar

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_
da-db_7msw.asp: Data Types

Shawn Aebi
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.|||Actually here is a link to the thread...
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=IsYbP1AdDHA.2408%40cpmsftngxa06.phx.gbl&rnum=1&prev=/groups%3Fq%3Dsql%2Bserver%2B17805%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26scoring%3Dd%26selm%3DIsYbP1AdDHA.2408%2540cpmsftngxa06.phx.gbl%26rnum%3D1|||i faced the same error, but found that i was executing "return" in the middle of the transaction and thus the bug was fixed by completing the transaction.

No comments:

Post a Comment