SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 ASP.NET
 System.Data.SqlClient.SqlException: A severe error occurred on the current command.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 06/17/2004 :  15:05:20  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Rashid writes "Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (http://support.microsoft.com/default.aspx?scid=kb;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...."

MichaelP
Jedi Yak

USA
2489 Posts

Posted - 06/17/2004 :  17:25:58  Show Profile  Visit MichaelP's Homepage  Reply with Quote
Post the .Net code and the Stored proc in question so we can figure it out.

Michael

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

frankburch
Starting Member

1 Posts

Posted - 06/23/2004 :  11:50:35  Show Profile  Reply with Quote
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:

CREATE PROCEDURE CreatePublication AS

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

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"


Try
If adoConnection.State <> ConnectionState.Open Then
adoConnection.Open()
End If
adoCommand4.CommandTimeout = 120
adoCommand4.ExecuteNonQuery()

adoConnection.Close()
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?

thanks,
frank
Go to Top of Page

ewallace
Starting Member

USA
2 Posts

Posted - 07/16/2004 :  15:58:28  Show Profile  Reply with Quote
I got this same error. Adding SET NOCOUNT ON seemed to fix it.


CREATE PROCEDURE CreatePublication AS
SET NOCOUNT ON
EXEC sp_addmergepublication
@publication = N'TESTDB',
@allow_anonymous = N'true'
GO

- Eric

Feel free to axe me any questions. I gots me a good edumacation.

Edited by - ewallace on 07/16/2004 15:58:59
Go to Top of Page

JRomero
Starting Member

USA
1 Posts

Posted - 11/18/2004 :  13:50:48  Show Profile  Reply with Quote
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

ward0093
Starting Member

USA
15 Posts

Posted - 02/25/2008 :  10:17:55  Show Profile  Visit ward0093's Homepage  Reply with Quote
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,
)
AS
SET NOCOUNT ON
BEGIN

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

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

RETURN (0)
END

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

For i As Int16 = 0 To 5000 'MAX OF TWO MINUTES, THEN EXIT REGARDLESS
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
Description:
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

jsolutions
Starting Member

1 Posts

Posted - 11/18/2008 :  11:02:55  Show Profile  Reply with Quote
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

gongyong1113
Starting Member

1 Posts

Posted - 06/03/2013 :  06:44:33  Show Profile  Reply with Quote
A severe error occurred on the current command. The results, if any, should be discarded.

Edited by - gongyong1113 on 06/03/2013 06:50:05
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000