web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Could not find prepared statement with handle xxxx

(0) ShareShare
ReportReport
Posted on by 10

hello,

we got "Could not find prepared statement with handle 4075." errors lately on some NST instances, and we had to restart the NST to make it work. it seem related to the NavSession.GetPersonalization().

we are using Nav2017 with SQL2016. here is the detailed info...please help!

Server instance: Nav_Prod_Nst8
Tenant ID: <ii>default</ii>
<ii>Session type: RoleTailoredClient
Session ID: 518
User: xxx\kg
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 4075.
SQL statement:
SELECT "timestamp","User SID","Profile ID","Language ID","Company","Debugger Break On Error","Debugger Break On Rec Changes","Debugger Skip System Triggers","Locale ID","Time Zone","Corix User ID" FROM "Dynamics NAV Production CWP".dbo."User Personalization" WITH(READUNCOMMITTED) WHERE ("User SID"=@0) OPTION(OPTIMIZE FOR UNKNOWN)
StackTrace:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_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.ExecuteFindEqualCommand(FilterExpression filter, NavDatabase database, Int32 companyIndex)
at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteCommandAndCacheOnSuccess[T](NavSqlCommandCacheKey commandKey, Func`1 createFunc, Func`2 executeFunc)
at Microsoft.Dynamics.Nav.Runtime.NavSqlIsamQueryCommand.FindEqual(NavDatabase database, RecordIdProviderRequest request)
at Microsoft.Dynamics.Nav.Runtime.SqlTableDataProvider.TryGetByPrimaryKey(RecordIdProviderRequest request, ReadOnlyRecordBuffer& recordBuffer)
at Microsoft.Dynamics.Nav.Runtime.DataAccess.InternalTryGetByPrimaryKey(RecordIdCacheRequest request, MutableRecordBuffer& recordBuffer)
at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.FindRecordWithoutCheckingValues(DataError errorLevel, NavValue[] primaryKeyValues, FiltersAndMarks filtersAndMarks, Boolean useRecord, Boolean cacheOnly, Boolean calcAutoCalcFields)
at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.GetRecord(DataError errorLevel, NavValue[] values)
at Microsoft.Dynamics.Nav.Runtime.NavRecord.ALGet(DataError errorLevel, NavValue[] values)
at Microsoft.Dynamics.Nav.Runtime.NavSession.GetPersonalization()
at Microsoft.Dynamics.Nav.Runtime.NavSession.Open(Boolean useUserPersonalization, Byte[] licenseToUse, Boolean allowAppsDisabledMode)
at Microsoft.Dynamics.Nav.Service.NSService.OpenConnection(ConnectionRequest connectionRequest)
at SyncInvokeOpenConnection(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, String syncMethodName, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.PushPopCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, String syncMethodName, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.CreateNewSessionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Boolean requireNavUser, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass8_0.<PerformanceCounterCombinator>b__0()
at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationDuration(Stopwatch stopWatch, Action action)
at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationAction(Action action, NavSession session)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.PerformanceCounterCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, String syncMethodName, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.InitClientTelemetryIdsCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, String syncMethodName, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TlsClearCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, String syncMethodName, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass23_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.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)
at System.ServiceModel.Dispatcher.MessageRpc.Wrapper.Resume(Boolean& alreadyResumedNoLock)
at System.ServiceModel.Dispatcher.ThreadBehavior.ResumeProcessing(IResumeMessageRpc resume)
at Microsoft.Dynamics.Nav.Runtime.NavSynchronizationContext.<>c__DisplayClass1_0.<ClearThreadLocalStorageDelegate>b__0(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()</ii>
HResult: -2146233088
----------------------------------
Type: System.Data.SqlClient.SqlException
ClientConnectionId: c56935ee-00b7-475b-af7c-85e49f9af52e
Class: 16
LineNumber: 1
Number: 8179
Server: DWP-AGL-NAV
State: 1
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: <ii>Could not find prepared statement with handle 4075.</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>

I have the same question (0)
  • zabaq Profile Picture
    on at

    Hello Henry,

    I have same error "Could not find prepared statement with handle xxx" in "NAV 2015 (8.0.42951.0)" on "SQL2014 SP3"... After Windows and install SP3 on SQL Server...

    Please, did you solved this issue?

    KInd Regards

    Tomas

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,066

#2
YUN ZHU Profile Picture

YUN ZHU 658 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 595

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans