Sunday, December 8, 2013

Code to connect to an External Database from X++ Code (AX 2012)



static void theAxapta_ODBCConnection(Args _args)
{
    LoginProperty   loginProp;
    ODBCConnection  conn;
    Resultset       resultSet, resultSetCount;
    Statement       statement1;
    ;
    loginProp = new LoginProperty();
    loginProp.setServer('theAxapta');//you can use IP address as well
    loginProp.setDatabase('AXDEVDB');
    conn = new ODBCConnection(loginProp);
    statement1  = conn.createStatement();
    resultSet   = statement1.executeQuery("SELECT * from CustTable where DATAAREAID = 'CEU'");
    while (resultSet.next())
    {
        info(resultSet.getString(1));
    }

}

No comments:

Post a Comment