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

I have a strange situation on a database, which are on SQL Server 2008 R2 Express SP2. The database size is something around 90 MB.

I have a strange situation on a database, which are on SQL Server 2008 R2 Express SP2. The database size is something around 90 MB.

When a user try to insert a record inside one table, he receive an error message,  and the program is disconnected from the database. I tried to investigate this issue, and I discovered that when user try to insert one row  the trigger for
insert invoke also the trigger for update and sql server crushes with «A severe error occurred on the current command.  The results, if any, should be discarded.»

I have checked from SQL Server Management Studio to run a direct Update on the specific table. The same error occurred.

I have run DBCC CheckTable and no errors have been found. I also have run DBCC CHECKDB and no errors.

Because I also have 3 other different databases, with the same functionality, on the same server which are going well with more than 100 000 records in that specific table, and the triggers are going well for more than 5 years, I have assumed that some
problems occurs inside the database. That is why I have copied all the records from the «damage» database to a new one. This means that inside the new databases the indexes are regenerated and a new space will be allocated.

The same strange things are happening. The same table can not be updated with a very basic Update statement.

I am looking for a patch or KB to solve this issues.

Any ideas are will be appreciated.

Thank you

  • Moved by

    Sunday, August 18, 2013 8:08 AM

Содержание

  1. A severe error occurred on the current command. The results, if any, should be discarded. Msg 0, Level 11, State 0, Line 0
  2. Severe error occurred on the current command the results if any should be discarded
  3. Answered by:
  4. Question
  5. Answers
  6. Severe error occurred on the current command the results if any should be discarded
  7. Answered by:
  8. Question
  9. Answers
  10. Severe error occurred on the current command the results if any should be discarded
  11. Answered by:
  12. Question
  13. Severe error occurred on the current command the results if any should be discarded
  14. Asked by:
  15. Question
  16. All replies

A severe error occurred on the current command. The results, if any, should be discarded. Msg 0, Level 11, State 0, Line 0

On my SQL 2017 Server, i created the below stored procedure to read error logs in SQL. The Stored proc gets created successfully, but when i execute the proc, it throws me this error.
Can anyone please help.

Basically i am trying to create a stored procedure , which will fetch the error details, within the recent 10 mins, when we pass the error number. But somehow it seems to be failing giving the error mentioned in subject , when i execute my proc. i execute this procedure on a newly created SQL database.

Track_ErrorLog @ErrNum=’18456′. Below is my proc code.

Not what they call a god user experience.

First about the error that you get. This basically means «internal error». That is, not your fault (at least not directly). This error can appear with severity 20 or 11. With 20 the accident happens in SQL Server, but you have severity 11 which means that the exception occurs in SSMS (or more precisely in SqlClient). I have found that in most cases this is due to SQL Server sending bad TDS. This is usually due to that something «unusual» happened.

Since this unusual is often an exception, I ran a trace with Error:Exception added, but I found no exception and that the procedure ran to the end.

But I have an experience of that INSERT-EXEC with extended stored procedures can be a bit unpolished. So I ran the call to xp_readerrorlog on its own, and voilГ , now I got an error message:

Msg 22004, Level 12, State 1, Line 0
Error executing extended stored procedure: Invalid Parameter Type

So what are the correct data types? I took my chances, but nothing helped. I went to Google, and found https://www.mssqltips.com/sqlservertip/1476/how-to-read-log-file-in-sql-server-using-tsql/
and learnt that for later SQL Server versions, you need double quotes:

Why this works, and not single quotes — I don’t know. But it seems really crazy to me.

And, more sadly, I could get it to work with the @ErrNum variable, but it has a to be a constant, so if you want it to be a variable, you would need dynamic SQL.

Finally, I should point out that xp_readerrorlog is an undocumented stored procedure, and thus not supported for direct use.

Источник

Severe error occurred on the current command the results if any should be discarded

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

on an sql server instance (version: 10.0.1600.22) i have a table which has no pk no index no constraint no key with several columns.

when I execute the following commands in management studio, i get the error: «A severe error occurred on the current command. The results, if any, should be discarded.»

However the following sql commands executed properly without error

what should i do?

Answers

So the error indicates that there was a crash either in the server or in the client API. If the problem is in the server, you should find a stack dump in the SQL Server error log. To determine if the error is on the client side, try running the same commands from SQLCMD that uses OLE DB, in difference to SSMS that uses SqlClient.

Since you have the RTM version of SQL 2008, my recommendation is that you install Service Pack 3 to see if this resolves the issue, before you make any other investigations.

Источник

Severe error occurred on the current command the results if any should be discarded

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I happened to notice backups on one of our SQL instance began to fail unexpectedly. Looking the job history I found out that they have failed with the error:

Executing the query «EXECUTE master.dbo.xp_delete_file 0,N’I:BackupsBLAH_BLAHFull’,N’bak’,N’2011-05-03T21:00:58′ » failed with the following error: «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.».

Seeing this my first thought was to go through the SQL server errorlog. But after executing master..xp_readerrorlog I see:

Msg 0, Level 11, State 0, Line 0

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

Msg 0, Level 20, State 0, Line 0

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

(I tried the GUI too — same error). So I manually loaded the errorlog into a notepad. Lot of stack dumps generated. The start of each dump looked like this.

2011-05-08 00:00:25.13 spid79 * BEGIN STACK DUMP:

2011-05-08 00:00:25.13 spid79 * 05/08/11 00:00:25 spid 79

2011-05-08 00:00:25.13 spid79 *

2011-05-08 00:00:25.13 spid79 *

2011-05-08 00:00:25.13 spid79 * Exception Address = 000007FF7FC51D71 Module(msvcrt+0000000000051D71)

2011-05-08 00:00:25.13 spid79 * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION

2011-05-08 00:00:25.13 spid79 * Access Violation occurred reading address FFFFFFFFFFFFFFFF

2011-05-08 00:00:25.13 spid79 * Input Buffer 198 bytes —

2011-05-08 00:00:25.13 spid79 * EXECUTE master.dbo.xp_delete_file 0,N’I:Backupsblah’,N’ba

2011-05-08 00:00:25.13 spid79 * k’,N’2011-05-01T00:00:23′

So the backups were taken; but it has a problem doing the cleanup.

The event logs too had almost the same thing to say.

— For the errorlog.

Exception happened when running extended stored procedure ‘xp_readerrorlog’ in the library ‘xpstar90.dll’. SQL Server is terminating process 68. Exception type: Win32 exception; Exception code: 0xc0000005.

Exception happened when running extended stored procedure ‘xp_delete_file’ in the library ‘xpstar90.dll’. SQL Server is terminating process 91. Exception type: Win32 exception; Exception code: 0xc0000005.

The SQL server version is

Microsoft SQL Server 2005 — 9.00.3042.00 (X64)

Feb 10 2007 00:59:02

Copyright (c) 1988-2005 Microsoft Corporation

Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

Any pointers to resolve these issues is highly appreciated.

Answers

Since all the errors are centered around calls to Extended Stored Procedures I would suspect your system got into memory pressure due to heavy multipage allocations and you possibly hit a out of memory state that lead to the stack dump occuring, and now you have residual issues from the dump. Have you tried restarting the SQL Server instance since the stack dump occurred?

Unfortunately, in the case of stack dumps, trying to solve them over the forums is usually pretty unproductive because it usually requires cracking the dump files with windbg and the SQL Server symbols to identify the dump exception and then walk the call stack for further troubleshooting. This is something that Product Support Services does as a part of support call when they encounter a SQL Server dumping out an exception.

Источник

Severe error occurred on the current command the results if any should be discarded

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

We have a DotNet website which is deployed on a physical server(windows server 2008 r2). The application is started to using for live. Most of the time application is working fine. But some times we have noticed the application is failed to communicate with MS SQL 2008 R2 database and as result the below error is displaying:

«A severe error occurred on the current command. The results, if any, should be discarded. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) «

If we tried to connect the database server the same issue is showing:»A severe error occurred on the current command. The results, if any, should be discarded»

The issue will be resolved automatically after 30-45 minutes . Please let us know if any fixes can be done to resolve this issue.

NOTE: We have installed SQL Server 2008 service pack 3 as per the suggestion from experts .But still the issue pwersist.

Источник

Severe error occurred on the current command the results if any should be discarded

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Asked by:

Question

When i executing the below open query into sql server then it fetch the data but shows the below error messgae :

Msg 0, Level 11, State 0, Line 0

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

Msg 0, Level 20, State 0, Line 0

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

I am using this query into Sql Server 2008 R2 with service pack 2 .

how can i resolve this issue and the same query is running fine into other server.Please provide the solution.

Thanks n advance.

And what version and service pack level does the other server have?

This error indicates that a severe error happens in SQL Server, so that SQL Server had to terminate your connection. Such errors are never due to user errors, but are due bugs in SQL Server, bad hardware or corrupion to to bad hardware.

In this case, I see that OPENQUERY is involved. What sort of data source is N99SYS00MSES? Is that another SQL Server instance? If this OLE DB provider is faulty and experience an error like an access violation, this can also produce this bad outcome.

In the SQL Server errorlog, you should find a stack dump which corresponds to this violent termination. The stackdump should give an indication where the error occurs.

Источник

Running the following query in SQL Server Management Studio gives the error below.

update table_name set is_active = 0 where id  = 3

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

  • The logs have been truncated
  • there is an update trigger but this isnt the issue
  • the transaction count is zero (@@trancount)

I have tried the same update statement on a couple of other tables in the database and they work fine.

DBCC CHECKTABLE('table_name');

gives

DBCC results for 'table_name'.
There are 13 rows in 1 pages for object "table_name".
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

p.campbell's user avatar

p.campbell

97.4k67 gold badges255 silver badges319 bronze badges

asked Jul 24, 2009 at 0:34

Paul Rowland's user avatar

Paul RowlandPaul Rowland

8,24412 gold badges55 silver badges76 bronze badges

1

I just had the same error, and it was down to a corrupted index.
Re-indexing the table fixed the problem.

Clint's user avatar

Clint

2,67622 silver badges42 bronze badges

answered Aug 18, 2010 at 16:23

LauraB's user avatar

2

In my case,I was using SubQuery and had a same problem. I realized that the problem is from memory leakage.

Restarting MSSQL service cause to flush tempDb resource and free huge amount of memory.
so this was solve the problem.

answered Jan 7, 2013 at 7:06

ARZ's user avatar

ARZARZ

2,4513 gold badges34 silver badges56 bronze badges

0

Run DBCC CHECKTABLE('table_name');

Check the LOG folder where the isntance is installed (Program FilesMicrosoft SQL ServerMSSQL.1MSSQLLOG usually) for any file named ‘SQLDUMP*

answered Jul 24, 2009 at 0:39

Remus Rusanu's user avatar

Remus RusanuRemus Rusanu

286k40 gold badges430 silver badges565 bronze badges

2

answered Jul 24, 2009 at 4:12

gbn's user avatar

gbngbn

417k81 gold badges581 silver badges670 bronze badges

1

In my case, I was using System.Threading.CancellationTokenSource to cancel a SqlCommand but not handling the exception with catch (SqlException) { }

answered Apr 12, 2017 at 22:14

Leo Gurdian's user avatar

Leo GurdianLeo Gurdian

2,05416 silver badges20 bronze badges

1

This error is exactly what it means: Something bad happened, that would not normally happen.

In my most recent case, the REAL error was:

Msg 9002, Level 17, State 2, Procedure MyProcedure, Line 2 [Batch Start Line 3]
The transaction log for database 'MyDb' is full due to 'LOG_BACKUP'.

Here is my checklist of things to try, perhaps in this exact order:

  1. Check if you’re out of disk space (this was my real problem; our NOC did not catch this)
  2. Check if you’re low on memory
  3. Check if the Windows Event Log shows any serious system failures like hard drives failing
  4. Check if you have any unsafe code loaded through extended procedures or SQLCLR unsafe assemblies that could de-stabilize the SQLServer.exe process.
  5. Run CheckDB to see if your database has any corruption issues. On a very large database, if this stored procedure only touches a sub-set of tables, you can save time by seeing which partitions (filegroups) the stored procedure touches, and only checking those specific filegroups.
    1. I would do this for your database and master db as well.

answered Jun 6, 2019 at 17:33

John Zabroski's user avatar

John ZabroskiJohn Zabroski

2,1442 gold badges27 silver badges53 bronze badges

3

This seems to happen when there’s a generic problem with your data source that it isn’t handling.

In my case I had inserted a bunch of data, the indexes had become corrupt on the table, they needed rebuilding. I found a script to rebuild them all, seemed to fix it. To find the error I ran the same query on the database — one that had worked 100+ times previously.

answered Oct 20, 2019 at 22:46

Paul Hutchinson's user avatar

Paul HutchinsonPaul Hutchinson

7791 gold badge12 silver badges27 bronze badges

in my case, the method: context.Database.CreateIfNotExists(); called up multiple times before create database and crashed an error A severe error occurred on the current command. The results, if any, should be discarded.

answered Dec 7, 2020 at 13:27

Silny ToJa's user avatar

Silny ToJaSilny ToJa

1,6271 gold badge5 silver badges15 bronze badges

I was having the error in Hangfire where I did not have access to the internal workings of the library or was I able to trace what the primary cause was.

Building on @Remus Rusanu answer, I was able to have this fixed with the following script.

    --first set the database to single user mode
    ALTER DATABASE TransXSmartClientJob
    SET SINGLE_USER
    WITH ROLLBACK IMMEDIATE;
    GO

    -- Then try to repair
    DBCC CHECKDB(TransXSmartClientJob, REPAIR_REBUILD)

    -- when done, set the database back to multiple user mode
    ALTER DATABASE TransXSmartClientJob
    SET MULTI_USER;
    GO

answered Aug 28, 2020 at 11:46

Shittu Joseph Olugbenga's user avatar

One other possible solution we just found after having this issue across multiple databases/tables on the same server.

Is the max connections open to the sql server. We had an app that wasn’t closing it’s SQL connection and was leaving them open so we were running around 28K-31K connections (SQL Sever has a max out at 32K ish), and we noticed that once we killed a few thousand sleeping connections it took care of the error listed on this question.

The fix was to update the apps to make sure they closed their connections instead of leaving them open.

answered Oct 21, 2020 at 15:36

tryonlinux's user avatar

tryonlinuxtryonlinux

1081 silver badge11 bronze badges

In my case it was something else, += operator caused this. I had to replace += X with field = field + X to overcome this. I assume this is a bug though I wasn’t able to find any related KB on Microsoft sites.

I am using SQL Server 2008 R2(10.50.1600).

answered Jan 4, 2021 at 9:44

MelOS's user avatar

MelOSMelOS

5555 silver badges10 bronze badges

Just wanted to add my 2cents to help whomever the next person that comes across this is.

We noticed that a specific report was failing after half an hour. I assumed it was a timeout as the amount of data being returned was huge. It turns out the SSRS default timeout setting is 1800 seconds (30mins). I changed the setting on this specific report to run indefinitely with no timeout and that resolved our issue.

Next step is to identify ways to improve the performance of the MSSQL behind the report :)

answered Jun 14, 2022 at 3:21

L.Newell's user avatar

L.NewellL.Newell

981 gold badge2 silver badges12 bronze badges

I had the same issue but the table was too big the I couldn’t fix it from the UI or by dropping and creating all indexes.
So here is another way to solve this , or at least it worked for me.

  1. I have backed up the database to a BAK file
  2. I have create a new database from newly backed up file and called the new database the same name but with appendix of «_BK» like this : myDatabase_BK
  3. The «bad table» on the new database was already working well without the error — so it seems that the deployment fixed the problem for the new database
  4. So what left was to rename the bad table on the live database(myDatabase) and then to create the same table from the backup (after renaming myDatabase.myTable):select * into myDatabase.myTable from myDatabase_BK.myTable
  5. Make sure to create all indexes on the new table.

answered Jun 19, 2022 at 7:14

Gil Allen's user avatar

Gil AllenGil Allen

1,14914 silver badges23 bronze badges

I received this same exception, but it was due to the fact that I was using Polybase to issue a query to an external table from an API request that was enlisting in a Transaction via TransactionScopes. The exception thrown from ADO.Net was the unhelpful: «A severe error occurred on the current command».

However, in SSMS, I did the following which finally made me realize that it was the transaction that was causing this issue:

  • View Object Explorer
  • Expand the Management Node
  • Expand SQL Server Logs
  • View the current log, and the errors that are logged when this exception was logged.

I saw the following:

Unsupported transaction manager request 0 encountered. SQL Server Parallel DataWarehousing TDS endpoint only supports local transaction request for 'begin/commit/rollback'.

I then placed this particular query in another transaction scope, suppressing the transactionscope that it would have enlisted in, and it worked.

using (var transactionScope = this.transactionScopeFactory.Create(
    System.Transactions.TransactionScopeOption.Suppress,
    new System.Transactions.TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted },
    System.Transactions.TransactionScopeAsyncFlowOption.Enabled))
{
    // ... query

    transactionScope.Complete(); // Suppress scope option renders this unnecessary, but just a good habit
}

answered Nov 3, 2022 at 19:40

Seth Flowers's user avatar

Seth FlowersSeth Flowers

8,9502 gold badges29 silver badges42 bronze badges

Hello.

I happened to notice backups on one of our SQL instance began to fail unexpectedly. Looking the job history I found out that they have failed with the error:

Executing the query «EXECUTE master.dbo.xp_delete_file 0,N’I:BackupsBLAH_BLAHFull’,N’bak’,N’2011-05-03T21:00:58′  » failed with the following error: «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.».

Seeing this my first thought was to go through the SQL server errorlog. But after executing master..xp_readerrorlog I see:

Msg 0, Level 11, State 0, Line 0

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

Msg 0, Level 20, State 0, Line 0

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

(I tried the GUI too — same error). So I manually loaded the errorlog into a notepad. Lot of stack dumps generated. The start of each dump looked like this.

2011-05-08 00:00:25.13 spid79      * BEGIN STACK DUMP:

2011-05-08 00:00:25.13 spid79      *   05/08/11 00:00:25 spid 79

2011-05-08 00:00:25.13 spid79      *

2011-05-08 00:00:25.13 spid79      *

2011-05-08 00:00:25.13 spid79      *   Exception Address = 000007FF7FC51D71 Module(msvcrt+0000000000051D71)

2011-05-08 00:00:25.13 spid79      *   Exception Code    = c0000005 EXCEPTION_ACCESS_VIOLATION

2011-05-08 00:00:25.13 spid79      *   Access Violation occurred reading address FFFFFFFFFFFFFFFF

2011-05-08 00:00:25.13 spid79      * Input Buffer 198 bytes —

2011-05-08 00:00:25.13 spid79      *             EXECUTE master.dbo.xp_delete_file 0,N’I:Backupsblah’,N’ba

2011-05-08 00:00:25.13 spid79      *  k’,N’2011-05-01T00:00:23′

So the backups were taken; but it has a problem doing the cleanup. 

The event logs too had almost the same thing to say. 

— For the errorlog.

Exception happened when running extended stored procedure ‘xp_readerrorlog’ in the library ‘xpstar90.dll’. SQL Server is terminating process 68. Exception type: Win32 exception; Exception code: 0xc0000005.

—For xp_delette_file

Exception happened when running extended stored procedure ‘xp_delete_file’ in the library ‘xpstar90.dll’. SQL Server is terminating process 91. Exception type: Win32 exception; Exception code: 0xc0000005.

The SQL server version is 

Microsoft SQL Server 2005 — 9.00.3042.00 (X64) 

Feb 10 2007 00:59:02 

Copyright (c) 1988-2005 Microsoft Corporation

Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)

Any pointers to resolve these issues is highly appreciated.

Thank you.

I am using VS Studio 2105 to create a console app and SSMS 2014 v 12.0.410.

I am running a VB.Net console app that does polling on the 0 and 30 second mark. It will do this 24 by 7. As part of the process, a background thread is spawned. (See explanation below).

The database connection string is:

add key=»ConnectionString» value=»Server=xxxxx,14334;Database=xxx_dev;Uid=xxx_dev;Password=xxxxxx;MultipleActiveResultSets=true»

The class and its functions called for the open and closing of the database:

Dim strConnectionString As String = ConfigurationManager.AppSettings(«ConnectionString»)

Sub OpenDB()

If objConn.State = Data.ConnectionState.Open Then

objConn.Close()

End If

objConn.ConnectionString = strConnectionString

objConn.Open()

objCmd.Connection = objConn

objCmd.CommandType = Data.CommandType.Text

End Sub

Sub CloseDB()

objConn.Close()

End Sub

I customized the error message to get all that I could about it.

>A severe error occurred on the current command. The results, if any, should be discarded. —> State: 0 —> Source: .Net SqlClient Data Provider —> Error number: 0 —> Line number: 0 —> Line number: -2146232060 —> Class: 11 —> Procedure: —> Call stack: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ReliableSiteBandwidthPollingTester.Module1.SaveBandwidthPollingLog(Switch SaveSwitch, String& strMessage) in C:DansWork 2Working AreaSwitch Polling — design 3Tester appsReliableSiteBandwidthPollingTesterReliableSiteBandwidthPollingTesterModule1.vb:line 427

The polling process:

It interrogates a network switch gathering data. After the interrogation, it then executes a simple stored procedure 105 times which inserts a row into a table each time. It then starts a background thread which executes a «calculation process» stored procedure that uses the table just inserted into as well as other tables. It does inserts into another table — and potentially deletes. A transaction is used. It either commits or rolls back. However, I believe that the procedure does not finish before the next poll begins — the next 30 second mark.

The simple insert stored procedure has been tested stand-alone many times and works fine every time.

The more complicated «calculation process» stored procedure has been tested stand-alone many times and works fine every time.

I start the console app and it it polls 3 times and the fails with that error. Before failing, it writes the out 3 sets of 105 rows to the table. It also inserts 290 rows into another table as part of the process.

Sub PollSwitch(sender As Object, e As ElapsedEventArgs)

Dim strMessage As String = «»

Dim strPollError As String = «»

Dim bPollResult As Boolean

Dim NetworkSwitch As Switch

‘ This is the format to display as it is how it is stored in the info log table.

Dim dtFormat As String = «yyyy-MM-dd hh:mm:ss.fff»

If bErrorInThread = True Then

‘ There was an error in the background thread during the previous issuance of the thread. So do not continue.

strMessage = «Critical Error — in the background thread. See the ‘BandwidthInfoLog’ table. Refer to this log date: » + dtThreadStartDateTime.ToString(dtFormat)

End If

If strMessage = «» Then

‘ Create a new instance.

NetworkSwitch = New Switch(strCommandLineSwitchIP, strCommandLineCommunityString)

Try

‘ Do the switch polling.

bPollResult = NetworkSwitch.Poll(strPollError)

If bPollResult = False Then

strMessage = «Warning — in bandwidth poll. Poll error at » & Now & «: » & strPollError & » Poll will continue.»

Else

‘ Save to the bandwidth polling log.

SaveBandwidthPollingLog(NetworkSwitch, strMessage)

If InStr(strMessage, «Critical») = 0 Then

Console.WriteLine(«Successfully polled at » & Now() & «.»)

‘ Set the date/time as it will be used above in an error message should the thread process fail.

dtThreadStartDateTime = Now()

»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

‘ Now do the «calculation process» — it will be in it’s own background thread.

‘ Note: the thread ends when the ProcessCalculatedSwitchPolling method ends.

»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

Dim thread As New Thread(AddressOf ProcessCalculatedSwitchPolling)

thread.Start()

End If

End If

Catch ex As Exception

strMessage = «Critical Error — in bandwidth poll — » & ex.Message & «

Switch: » & strCommandLineSwitchIP

End Try

End If

If InStr(strMessage, «Critical») > 0 Then

‘ Stop this method (this poll timer) as there is a critical error.

DisposeTimer()

‘ Show message.

Console.WriteLine(strMessage)

Console.WriteLine(«———>>>> PRESS ENTER TO QUIT.»)

Console.ReadKey()

‘ Exit the console application here as there is a critical error.

‘ Normally the exit would occur in the main method when the User hits a key.

Environment.Exit(0)

End If

End Sub

The call stack shows it fails on line 427 which is the .ExecuteNonQuery() line.

Sub SaveBandwidthPollingLog(ByVal SaveSwitch As Switch, ByRef strMessage As String)

Const strFunctionId As String = «VB — savebandwidthpollinglog. Error ID: «

Const iSQLErrorId As Integer = 501

Const iCATCHErrorId As Integer = 502

Dim dtCurrentDateTime As Date = Now()

Dim strProcessInfoLogResult As String = «»

Dim strAdditionalInfoForLog As String = «»

‘ This is the format to display as it is how it is stored in the info log table.

Dim dtFormat As String = «yyyy-MM-dd hh:mm:ss.fff»

DBFunc.OpenDB()

Try

With DBFunc.objCmd

.CommandType = Data.CommandType.StoredProcedure

.CommandText = «InsertBandwidthLogTest6»

‘ Note: it was timing out, so the SqlCommand.CommandTimeout property has expired; the default timeout is 30 seconds.

.CommandTimeout = 0

For Each SavePort In SaveSwitch.Port

.Parameters.Clear()

.Parameters.AddWithValue(«@SwitchIP», SaveSwitch.IP)

.Parameters.AddWithValue(«@PortIndex», SavePort.Index)

.Parameters.AddWithValue(«@PortSpeed», SavePort.Speed)

.Parameters.AddWithValue(«@InOctets», SavePort.InOctets)

.Parameters.AddWithValue(«@OutOctets», SavePort.OutOctets)

.Parameters.AddWithValue(«@TimeStamp», SavePort.TimeStamp)

.ExecuteNonQuery()

Next

End With

Catch sqlex As SqlException

‘ Its a critical issue.

If InStr(sqlex.Message, «Critical») > 0 Then

‘ Coming from the stored procedure.

strMessage = sqlex.Message

Else

strProcessInfoLogResult = ProcessInfoLog(dtCurrentDateTime, sqlex.Message + » —> State: » + sqlex.State.ToString() + » —> Source: » + sqlex.Source + » —> Error number: » + sqlex.Number.ToString() + » —> Line number: » + sqlex.LineNumber.ToString() + » —> Line number: » + sqlex.HResult.ToString() + » —> Class: » + sqlex.Class.ToString() + » —> Procedure: » + sqlex.Procedure + » —> Call stack: » + sqlex.StackTrace, strAdditionalInfoForLog, strFunctionId, iSQLErrorId)

End If

Catch ex As Exception

strProcessInfoLogResult = ProcessInfoLog(dtCurrentDateTime, ex.Message, strAdditionalInfoForLog, strFunctionId, iCATCHErrorId)

Finally

‘ Close database.

DBFunc.CloseDB()

End Try

End Sub

The Thread process:

Public Sub ProcessCalculatedSwitchPolling()

Const strFunctionId As String = «VB — processcalculatedswitchpolling. Error ID: «

Const iSQLErrorId As Integer = 601

Const iCATCHErrorId As Integer = 602

Dim strProcessInfoLogResult As String = «»

Dim strAdditionalInfoForLog As String = «»

Dim strInputParms As String = «»

‘ Set for the error log.

strInputParms = «S/P parmameters — switch IP Address: » & strCommandLineSwitchIP

DBFunc.OpenDB()

Try

With DBFunc.objCmd

.CommandType = Data.CommandType.StoredProcedure

.CommandText = «ProcessBandwidthLogCalculatedTest6»

‘ Note: it was timing out, so the SqlCommand.CommandTimeout property has expired; the default timeout is 30 seconds.

.CommandTimeout = 0

.Parameters.Clear()

.Parameters.AddWithValue(«@SwitchIP», strCommandLineSwitchIP)

.ExecuteNonQuery()

End With

Catch sqlex As SqlException

‘ Its a critical issue.

If InStr(sqlex.Message, «Critical») > 0 Then

‘ Coming from the stored procedure.

‘ Set the global variable — the thread error indicator.

bErrorInThread = True

Else

‘ Not coming from the stored procedure.

bErrorInThread = True

‘ Log the exception as it was not logged in the stored procedure.

strAdditionalInfoForLog = strInputParms

strProcessInfoLogResult = ProcessInfoLog(dtThreadStartDateTime, sqlex.Message, strAdditionalInfoForLog, strFunctionId, iSQLErrorId)

End If

Catch ex As Exception

bErrorInThread = True

‘ Log the exception.

strAdditionalInfoForLog = strInputParms

strProcessInfoLogResult = ProcessInfoLog(dtThreadStartDateTime, ex.Message, strAdditionalInfoForLog, strFunctionId, iCATCHErrorId)

Finally

‘ Close database.

DBFunc.CloseDB()

End Try

End Sub

Понравилась статья? Поделить с друзьями:
  • A security error occurred when uploading this audio file
  • A script error has occurred insufficient memory to perform operation перевод
  • A schema validation error has occurred while validating the message tree
  • A sapphire internal error has occurred
  • A running instance of acrobat has caused an error как исправить