Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 System.Data.SqlClient.SqlException: A severe error occurred on the current command.

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2004-06-17 : 15:05:20
Rashid writes "Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (;en-us;827366) these errors happen due to following resons

1. You use a SqlClient class in a Finalize method or in a C# destructor.

2. You do not specify an explicit SQLDbType enumeration when you create a SqlParameter object. When you do not specify an explicit SQLDbType, the Microsoft .NET Framework Data Provider for SQL Server (SqlClient) tries to select the correct SQLDbType based on the data that is passed. SqlClient is not successful.

3. The size of the parameter that you explicitly specify in the .NET Framework code is more than the maximum size that you can use for the data type in Microsoft SQL Server.

None of these are true in my case. Are there any other reasons that can cause these problems..

Thanks in Advance...."

Jedi Yak

2489 Posts

Posted - 2004-06-17 : 17:25:58
Post the .Net code and the Stored proc in question so we can figure it out.


<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

Starting Member

1 Post

Posted - 2004-06-23 : 11:50:35
I'm with Rashid. Trying to create a publication, getting that error and it doesn't look like MS description matches what I am doing.

I am trying to create a publication from .NET. First i created a command object, used type of commandText and put the following code for text:

EXEC sp_addmergepublication
@publication = N'TESTDB',
@allow_anonymous = N'true'

This gives me stupid error:
A severe error occcurreeed......
when i run code from .NET.

So then I say, OK, make it a stored procedure. Now Sproc looks like this:


EXEC sp_addmergepublication
@publication = N'TESTDB',
@allow_anonymous = N'true'

And .NET Code looks like this:

Dim strConn As String = "Server=" & myLocalServer & _
";pwd=" & myPassword & _
";uid=" & myUserName & _
";Database=" & myDatabase

Dim adoConnection As SqlConnection = New SqlConnection(strConn)
Dim adoCommand4 As SqlCommand = New SqlCommand
adoCommand4.Connection = adoConnection
adoCommand4.CommandType = CommandType.StoredProcedure

'Setup the publication(s)

adoCommand4.CommandText = "CreatePublication"

If adoConnection.State <> ConnectionState.Open Then
End If
adoCommand4.CommandTimeout = 120

MsgBox("Done creating publication...")
Catch ex As Exception
MsgBox("pub error...." + ex.Message)
End Try

Of course I get the same error... A severe error occurred....

Interesting enough, I put a raise error in SPROC right before and after the call to sp_addmerge thing and i discover that the error is definitely being generated when that line in sproc runs, before anything gets passed back to .NET...

So then i just get curious, and I run the sproc from query analyzer.... and it works fine, no error. So it does have something to do with .NET, but i don't know way around this.

BTW, the results of this error occurring when i run this, it does create a publication that i can see in Enterprise Manager, but when i try to start the snap shot that was created i get this error:

Error 14262: The specified @job_id('asdfsdfasdfasdfadsfasdfsadfa some long hex number') does not exist.

any thoughts?

Go to Top of Page

Starting Member

2 Posts

Posted - 2004-07-16 : 15:58:28
I got this same error. Adding SET NOCOUNT ON seemed to fix it.

EXEC sp_addmergepublication
@publication = N'TESTDB',
@allow_anonymous = N'true'

- Eric

Feel free to axe me any questions. I gots me a good edumacation.
Go to Top of Page

Starting Member

1 Post

Posted - 2004-11-18 : 13:50:48
Hi all,

I hope that this reply aids those of you that have encountered the infamous “A severe error occurred command. The results, if any, should be discarded.” from System.Data.SqlCient in your .NET development.

I came across this same problem today and after a few hours was able to solve the issue.

In my application, I was calling an INSERT stored proc; which would then fire a TRIGGER on insert. This trigger’s job was to map to another server and perform a file move. The file move was done via Windows/DOS NET USE command.

NOTE: The stored proc was working just great until we inserted the TRIGGER logic.

The problem was that the user id used to perform the connection to the data store DID NOT have sufficient Windows privileges to perform NET USEs. And that my friends, was the cause of my “SEVERE ERROR”.

I am not sure if this may be the case in some of your cases, but hopefully it will guide you in the right direction into trying to examine what kind of privileges are needed for the task(s) performed by your TRIGGER.

Good luck,

Here is what I was attempting to do within my .NET application.

Juan Romero
Sr. Applications Developer
Health New England
Springfield, MA 01144
Go to Top of Page

Starting Member

15 Posts

Posted - 2008-02-25 : 10:17:55
I have five machines running the same SQL Server Database (structure) but obvously with different data.

I get this "Severe Error" inconsistantly on just one machine. But it is always erroring out on the same spot (same SP). Here is my .NET code and my SP

CREATE PROCEDURE dbo.V2_NetworkItemType_Select_AllInfo
@productsNetworkItemTypesID uniqueidentifier,

SELECT ProductsNetworkItemTypesID, ParentNetworkItemTypesID, Name, Code, Description, DefaultDisplayOrder,
IsTaxable, IsFlexAccountEligible, IsDefault, IsDeleted, DateCreated, DateLastModified, UserLastToModify
FROM ProductsNetworkItemTypes WITH (NOLOCK)
WHERE ProductsNetworkItemTypesID = @productsNetworkItemTypesID

IF (@@ROWCOUNT <= 0)
RAISERROR (50001, 16, 1) WITH SETERROR; RETURN @@ERROR --No records found for this object.


scNIT = Core.GetSQLCommandObject(sqlConn, Data.CommandType.StoredProcedure)
Products.NetworkItemType.GetObjectFetchParameters(scNIT, New Products.NetworkItemType.FetchFilter(NetworkItemTypesID, True, True))
iarNIT = scNIT.BeginExecuteReader()

If i > 0 Then Threading.Thread.Sleep(25)
If iarNIT IsNot Nothing AndAlso Not iarNIT.IsCompleted Then Continue For
Exit For 'if we get here, exit
Next i

Using sdr As New Core.SmartDataReader(scNIT.EndExecuteReader(iarNIT))
If sdr.Read() Then Me.NetworkItemType = Products.NetworkItemType.GetChild(sdr)
End Using

it errors out on the third to the last .NET line "Using sdr As New Core.SmartDataReader(scNIT.EndExecuteReader(iarNIT))" and I can not figure it out. Would corrupt data cause this? I looked at the ProductsNetworkItemTypes Table and the data looks good... so what am I missing?

Here is my error message:
Event Type: Error
Event Source: capevents
Event Category: None
Event ID: 0
Date: 2/22/2008
Time: 2:09:49 PM
User: N/A
Computer: GRPOS2
A severe error occurred on the current command. The results, if any, should be discarded.
A severe error occurred on the current command. The results, if any, should be discarded.

Error occurred in [LineItemPurchased/NetworkItem: FetchChildData] method.
Error occurred in [LineItemPurchased/LineItemBase: FetchChildData] method.
Error occurred in [LineItemPurchased/ActiveBusinessBase`1: FetchChildData] method.
Error occurred in [LineItemPurchased/ActiveBusinessBase`1: ClearingData] method.

SQL Database Error Information on Server: .\SQLExpress
Stored Procedure: N/A
Error Number: 0 - Error Code: -2146232060
LineNumber: 0 - State: 0 - Class: 11

Stack Trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
at System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(IAsyncResult asyncResult, String endMethod)
at System.Data.SqlClient.SqlCommand.EndExecuteReader(IAsyncResult asyncResult)
at test.CMS.BusinessCore.Products.NetworkItem.FetchChildData(CriteriaBase criteria, SqlConnection sqlConn) in D:\Development\test.Projects.2005\test.CMS.BusinessCore\Products\NetworkItem.DataAccess.vb:line 138
Go to Top of Page

Starting Member

1 Post

Posted - 2008-11-18 : 11:02:55
Adding my $.02...

I encountered this error in a stored proc. Not seeing anything obvious and having covered all previously mentioned scenarios, on a hunch, I changed my stored proc to stop using a temp table and start using a table variable.

The proc created a temp table, inserted some rows, did some updates to the temp table and then returned the results as a query in the stored proc.

When I changed the temp storag from a temp table to a table variable, the error went away.

I can't necessarily explain it, but I can identify this as the change that eliminated the error.
Go to Top of Page

Starting Member

1 Post

Posted - 2013-06-03 : 06:44:33
A severe error occurred on the current command. The results, if any, should be discarded.
Go to Top of Page

- Advertisement -