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

Disabling the flight in D365FO (CHD - Tier 1)

 INSERT INTO dbo.SYSFLIGHTING(FLIGHTNAME, ENABLED)  VALUES ('<FlightObjectName>_KillSwitch', 1)  or  INSERT INTO dbo.SYSFLIGHT...