Sunday, March 6, 2016

SQL ODBC Connection to another DB

//SQL ODBC Connection to another DB
static void SQLODBCConnection(Args _args)
{
    OdbcConnection con;
    SqlSystem       sq;
    LoginProperty   loginProperty;
    Statement statement1;
    ResultSet myResult1;
    str sqlStmnt;
    SqlStatementExecutePermission perm;
    sq = new SqlSystem();
    loginProperty = new LoginProperty();
    loginProperty.setServer("AOSSERVER");
    loginProperty.setDatabase("MicrosoftDynamicsAX");
    con = new OdbcConnection(loginProperty);
    sqlStmnt = strFmt("select * from Fcc_BankChequeMenus"); //write your query here
    statement1 = con.createStatement();
    perm = new SqlStatementExecutePermission(sqlStmnt);
    perm.assert();
    myResult1  = statement1.executeQuery(sqlStmnt);
    while(myResult1.next())
    {
        info(myResult1.getString(4));
        info(myResult1.getString(5));
        info(myResult1.getString(6));
        info(myResult1.getString(7));
    }
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...