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 :
Microsoft Dynamics NAV (Archived)

NAV Service Error

(0) ShareShare
ReportReport
Posted on by 192

Hello Team,

Can anyone helo me with this error: I am getting this error when connecting with NAV 2016

---Log Details---
Server instance: XXXXX
Tenant ID:
User:
Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavSqlException
ErrorNumber: 102
SuppressMessage: False
SuppressExceptionCreatedEvent: False
FatalityScope: None
Message:
  The following SQL error was unexpected:
  Incorrect syntax near '='.
  Statement(s) could not be prepared.
  SQL statement:
  DECLARE @LastActiveDate AS DATETIME = GETUTCDATE();UPDATE [TEST_FS].dbo.[Server Instance] SET [Last Active] = @LastActiveDate WHERE [Server Instance ID] = @0;SELECT IIF(@@ROWCOUNT = 0, NULL, @LastActiveDate)
  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.ExecuteFunction[T](Func`1 function, NavSqlCommand command)
     at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.<>c__DisplayClass12`1.<ExecuteFunctionWithTrace>b__11()
     at Microsoft.Dynamics.Nav.Runtime.NavSqlCommand.ExecuteScalar()
     at Microsoft.Dynamics.Nav.Runtime.Heartbeat.<>c__DisplayClass2.<ExecuteWriteHeartbeatToServiceInstanceTable>b__1()
     at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithDuration(Stopwatch stopWatch, Action action, NavPerformanceCounterEntry performanceCounterEntry)
     at Microsoft.Dynamics.Nav.Runtime.Heartbeat.ExecuteWriteHeartbeatToServiceInstanceTable(NavDatabase database, NavSqlCommand updateCommand, NavSqlConnectionScope conScope)
     at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteCommandAndCacheOnSuccess[T](NavSqlCommandCacheKey commandKey, Func`1 createFunc, Func`2 executeFunc)
     at Microsoft.Dynamics.Nav.Runtime.Heartbeat.WriteHeartbeatToServiceInstanceTable()
     at Microsoft.Dynamics.Nav.Runtime.PeriodicScheduler.RunAction()
     at Microsoft.Dynamics.Nav.Runtime.ThreadPeriodicScheduler.DoScheduledAction()
     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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()
HResult: -2146233088
----------------------------------
Type: System.Data.SqlClient.SqlException
ClientConnectionId: XXXXXXXXXXXX
Class: 15
LineNumber: 1
Number: 102
Server: XXXXXXX
State: 1
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message:
  Incorrect syntax near '='.
  Statement(s) could not be prepared.
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)
     at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, 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 asyncWrite)
     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
     at System.Data.SqlClient.SqlCommand.ExecuteScalar()
     at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteFunction[T](Func`1 function, NavSqlCommand command)
HResult: -2146232060

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    IshwarSharma Profile Picture
    729 on at

    Please check this discussion. forum.mibuso.com/.../sql-error-when-upgrading-from-2009-2013-to-2016-cu-10

  • keoma Profile Picture
    32,729 on at

    did you run an upgrade?

    which sql server version do you use?

  • Mitr Profile Picture
    192 on at

    Yes we run upgrade from NAv 5.0 to NAV 2016.

    We are using SQL server 2008 R2. I know SQL server 2008 R2 is not supported with NAv 2016.

    However is there any way to get rid of this error?

    I have looked these links but no positive response:

    below link to Turn On or Off port sharing: computerstepbystep.com/net_tcp_port_sharing_service.html

    Additional links as well:

    www.waldo.be/.../port-sharing-with-nav-with-powershell

    www.waldo.be/.../port-sharing-with-nav2013

  • HenryHuang Profile Picture
    10 on at

    hi, did you fix the problem?

    I am getting the same error "Could not find prepared statement with handle ", can you please share your solutions?

    thanks!

  • Community Member Profile Picture
    on at

    A client reported the same problem on Nav 2016. This was implemented a couple of years ago, it's not an upgrade, and there were no recent changes.

    I restarted the Nav services, and the error did not appear again.

    Unfortunately, I don't know what caused it, or why it stopped occurring after the service restart.

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans