Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 17314

ODBC connection properties – setOther()

$
0
0

I’m working on an implementation that interfaces Dynamics AX to a number of external systems using an Enterprise Service Bus.

InterfaceOverview_Generic

The Enterprise Service Bus uses tables in a SQL Server database so we’re using an ODBC driver to move the data from Dynamics AX. The interfaces are coded in X++.

One of the first challenges we encountered is the requirement for record updates – first we do a select on the target table; if the returned resultset is null we can perform an insert otherwise we must perform an update. But the standard ODBC connection objects don’t support this by default. We need to use a feature of the native SQL Server ODBC driver called “Multiple Active Result Sets” (MARS), which is explained here. We do this in X++ like this:

protectedvoid initialiseForTSQL(){
    LoginProperty   login;
 
    login =new LoginProperty();
    login.setDSN(GCGInterfaceParameter::find().DSN);
    login.setOther('MARS_Connection=Yes');
 
    connection =new OdbcConnection(login);
}

The application was initially AX 2012 R2 with kernel build 6503 and everything worked well.

Last week, we upgraded the kernel to 9152 and the interfaces broke with this error:

Data source name not found and no default driver specified

We logged a support call with Microsoft and very promptly the engineer told us:

The problem occurs whenever we’re trying to initialise an ODBC connection from X++ and calling the setOther() method on the LoginProperty. The kernel change that introduced this was shipped with KB 2964481. The kernel code parses the parameters we specify in the connection string but then, if “other” parameters are specified using “setOther()”, we reset the connection stringand use these custom parameters.

So the call to setOther() which sets the MARS value removes the DSN we had specified and causes a logon error. There is no hotfix publicly available for KB2964481 but a solution is straightforward to code in X++. We specify all our connection values in the call to setOther() and our code now looks like this:

protectedvoid initialiseForTSQL(){
    LoginProperty   login;
    str             connectionString;
 
    login =new LoginProperty();
 
    connectionString =strFmt('DSN=%1;MARS=Yes', GCGInterfaceParameter::find().DSN);
    login.setOther(connectionString);
 
    connection =new OdbcConnection(login);
}

Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>