Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, November 3, 2014

Access the other instance DB belongs to same domain but different DB in AX

Hi,

static void AlfasithOtherDBAccess(Args _args)
{
    LoginProperty       loginProp;
    ODBCConnection      conn;
    Resultset           resultSet, resultSetCount; // get record
    Statement           statement1, statement2; // Create SQL Statement
    ResultSetMetaData   metaData ; // get Record metadate like columnname.
    RetailTillLayout    RetailTillLayout;
    int i = 1;
    ;

    // Set Server Database
    loginProp = new LoginProperty();
    loginProp.setServer('DNWADY0046L'); // System or  server name
    loginProp.setDatabase('MicrosoftDynamicsAX'); // instance DB name like MicrosoftDynamicsAX_Live

    // Create Connection and SQL Statement
    conn = new ODBCConnection(loginProp);
    statement1 = conn.createStatement();
    resultSet = statement1.executeQuery("SELECT TOP 1 * from [MicrosoftDynamicsAX].[dbo].[RetailTillLayout]");

    while (resultSet.next())
    {
        metaData = resultSet.getMetaData();
        while (i)
        {
            info("Column Name :"+metaData.getColumnName(i)+ " Value = "+resultSet.getString(i));
            i++;
        }
    }
}

Regards,

No comments:

Post a Comment

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...