Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

The following SQL error was unexpected: Could not find prepared statement with handle XXXXX / DYNAMICS NAV 2017 - WEB SERVICES INTEGRATION

(0) ShareShare
ReportReport
Posted on by 20

Platform

Dynamics NAV 2017 , Build 21440  - WinServer 2016, Version 10.0.14393, Build 14393.
SQL Server 2016, version 13.05598.27, installation in WinServer 2016, Version 10.0.14393, Build 14393.

Below, a short description from the customer.:

For some months now we have been having this type of error in production, in the X instance (the one that receives requests from system Y (local system designed and created by customer to control centralization of master codes) via WebService).

These errors, when they appear, usually last for a few hours and then disappear.

We have already been analyzing and searching the web for this type of error but we have not reached anywhere so far.

We have also changed some configuration parameters for the instance in question, but so far it has never solved this problem.

If we restart the NAV instance, the error will obviously disappear.

HERE IT IS THE LOG DATA:

Server instance: CSWDBWS Tenant ID: <ii>User: Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavSqlException ErrorNumber: 8179 SuppressMessage: False SuppressExceptionCreatedEvent: False FatalityScope: None Message: <ii>The following SQL error was unexpected: Could not find prepared statement with handle 25596. </ii> StackTrace: at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ThrowNavSqlException(SqlExceptionAdapter exceptionAdapter, NavSqlCommand command, Boolean isLastExceptionARollbackCause, Boolean logExceptions) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.<>c__DisplayClass100_0`1.<ExecuteFunction>b__0() at Microsoft.Dynamics.Nav.Types.NavThread.RunExternalAction[T](Func`1 action) at Microsoft.Dynamics.Nav.Diagnostic.NavDiagnostics.SendTraceTagOnThreshold[T](String tag, Category category, Verbosity verbosity, Int32 threshold, Func`1 action, String message, Object[] parameters) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteFunctionWithTrace[T](EventTask task, Func`1 function, NavSqlCommand command) at Microsoft.Dynamics.Nav.Runtime.NavSqlCommand.ExecuteReader() at Microsoft.Dynamics.Nav.Runtime.NavSqlIsamQueryCommand.ExecuteFindFirstLast(MutableRecordBuffer inputRecord, FilterExpression filter, DataLockState lockState, Int32 topRows, Boolean onlyCurrentKeyFields) at Microsoft.Dynamics.Nav.Runtime.NavSqlIsamQueryCommand.<>c__DisplayClass44_2.<FindAll>b__1(NavSqlCommand command) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteCommandAndCacheOnSuccess[T](NavSqlCommandCacheKey commandKey, Func`1 createFunc, Func`2 executeFunc) at Microsoft.Dynamics.Nav.Runtime.NavSqlIsamQueryCommand.<FindAll>d__44.MoveNext() at Microsoft.Dynamics.Nav.Runtime.ResultSet.TryGetAtIndex(Int32 index, ReadOnlyRecordBuffer& recordBuffer) at Microsoft.Dynamics.Nav.Runtime.ResultSetEnumerator.TryGetRecordBufferFromResultSet(Int32 fetchIndex, MutableRecordBuffer& recordBuffer) at Microsoft.Dynamics.Nav.Runtime.ResultSetEnumerator.TryMoveNextImpl(MutableRecordBuffer& recordBuffer) at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.Advance(Int32 steps, Boolean moveBackwards, Boolean automaticFindFromPositionOnInvalid, Boolean& resultSetValid, Int32 setSize) at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.IssueFindRequest(DataError errorLevel, Boolean reversed, FindType findType, Boolean useCache) at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.FindRecordImp(DataError errorLevel, String searchMethod) at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.FindRecord(DataError errorLevel, String searchMethod) at Microsoft.Dynamics.Nav.Runtime.NavRecord.ALFind(DataError errorLevel, String searchMethod) at Microsoft.Dynamics.Nav.Runtime.WebServiceView.SystemWebServiceTable.GetDisallowedObjects() at Microsoft.Dynamics.Nav.Runtime.WebServiceView.Create() at Microsoft.Dynamics.Nav.Service.WebMetadata.WebServiceTable.MoveFirst() at Microsoft.Dynamics.Nav.Service.WebMetadata.ServiceRegistry.<GetEnumerator>d__4.MoveNext() at Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.FindServiceItem(String fullName) at Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.DispatchSoap(WebServiceUrlInfo relivantURLPart, XmlReader input, TextWriter output, NavTenant tenant) at Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.Invoke(Boolean isSoapMessage, Uri url, XmlReader input, TextWriter output, NavUserAuthentication navUserAuth) at Microsoft.Dynamics.Nav.Service.WebServices.NavWebService.<>c__DisplayClass3_1.<ProcessMessage>b__2() at Microsoft.Dynamics.Nav.Service.WebServices.Disposer.Scope(Code code) at Microsoft.Dynamics.Nav.Service.WebServices.WCFUtil.GetPopulatedMemoryStream(StreamFillingCallback callback) at Microsoft.Dynamics.Nav.Service.WebServices.NavWebService.ProcessMessage(Message message) at SyncInvokeProcessMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) Source: Microsoft.Dynamics.Nav.Ncl HResult: -2146233088 ---------------------------------- Type: System.Data.SqlClient.SqlException ClientConnectionId: cd2f528c-952c-47f4-9bd4-ab7081949011 Class: 16 LineNumber: 1 Number: 8179 Server: SQLNAV2017.CRITICAL.PT\NAV2017 State: 1 Source: .Net SqlClient Data Provider ErrorCode: -2146232060 Message: <ii>Could not find prepared statement with handle 25596.</ii> StackTrace: at System.Data.SqlClient.SqlConnection.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.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) 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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.<>c__DisplayClass100_0`1.<ExecuteFunction>b__0() HResult: -2146232060 </ii>

  • Suggested answer
    THE Italian Profile Picture
    THE Italian on at
    RE: The following SQL error was unexpected: Could not find prepared statement with handle XXXXX / DYNAMICS NAV 2017 - WEB SERVICES INTEGRATION

    I think you are running an outdated build no. 

    Best suggestion is to deploy latest Cumulative Update. Currently CU 43. You can download the bits from https://www.microsoft.com/en-US/download/details.aspx?id=101357

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans