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

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...