Dynamics AX error: The fetch type refresh cannot be used with forward only cursors

I recently encountered a strange error in AX, where on opening a particular form, AX would throw an error saying “The fetch type refresh cannot be used with forward only cursors”.

Restarting the AOS, running full X++ recompile and full CIL generation did not resolve the problem.

“The fetch type refresh cannot be used with forward only cursors”

Continue reading “Dynamics AX error: The fetch type refresh cannot be used with forward only cursors”

Too many joins in query

In Dynamics AX 2012, if you are running a query with too many joins you can get an error or warning message saying “The number of joins in the statement is XX.  This exceeds the maximum of 26.  Turn on exception for this warning to see the call stack.”


So what is this, and what can you do about it?

Continue reading “Too many joins in query”

Failed to initialize the managed interoperability layer

As with most error messages in Dynamics AX, there are many different situations that can result in exactly the same error message.

Start-SmartDeploy : Failed to initialize the managed interoperability layer of Microsoft Dynamics AX.
At C:\Windows\refresh_staging.ps1:403 char:18
+ Start-SmartDeploy <<<< -Configuration Staging
+ CategoryInfo : NotSpecified: (:) [Start-SmartDeploy], Initializ
ationFailedException
+ FullyQualifiedErrorId : Microsoft.Dynamics.BusinessConnectorNet.Initiali
zationFailedException,SmartDeploy.PowerShell.Commands.StartSmartDeployCommand

I have seen quite a few suggested solutions for this particular one, including checking the versions of the .NET framework, .NET Business Connector installed on both the server and the client, using LogonAs() instead of Logon(), but in every single case I have seen this message, the solution has been….. embarrassingly… simple.

It has always been a case of the problem existing between the chair and the keyboard.

Continue reading “Failed to initialize the managed interoperability layer”

Retrieving date/datetime from ADO.NET into a record field

In Dynamics AX, you can use ADO.NET to retrieve data from external data sources.  This is quite easy to do for text and numeric data types, but not for Date or DateTime data types.

If you try a simple assign, you’ll end up throwing an exception:

blocks.Field1 = reader.get_Item( "REGISTRATIONDATE" );

Error executing code: Wrong argument types in variable assignment.

Using SqlDataReader.GetDataTypeName() to check the data type, it shows DateTime2.  The destination field is a datetime field, but this problem as well as the solution happens even for plain date fields.

So, we might try to use SqlDataReader.GetDateTime() instead, but that results in exactly the same error.

Continue reading “Retrieving date/datetime from ADO.NET into a record field”

Dynamics AX CIL is not incremental, just mental…

In Dynamics AX 2012, you may some times get this error message when generating CIL code:

Cannot create a record in SysXppAssembly (SysXppAssembly). The record already exists.

I see this quite frequently when generating incremental CIL, to the point where I consider incremental CIL to be thoroughly broken.  Do yourself a favour and do full CIL generation every time, you will save time in the long run from not having to troubleshoot weird and wonderful errors…

Also, I have made it a habit to delete the files directly under the xppIl folder for the relevant AOS when this happens.