Interview Questions

Monday, May 12, 2014

ODBC Connection Inbound in ax 2009

1.Set DSN connection.
2.static void ODBCConnectionInbound(Args _args)
  {
    LoginProperty   loginProp,loginProp1;
    ODBCConnection  conn,conn1;
    Resultset       resultSet, resultSetCount;
    Statement       statement1, statement2;
    TimeExpected    timeExpected;
    SqlStatementExecutePermission perm;
    N_LedgerJournal1  LedgerJournal,LedgerJournallocal;
    int    counter;
    str   value;
    container c;
    int i;
    #AviFiles
    str sql,valuesql;
    SysOperationProgress progress = new SysOperationProgress();
    ;

    loginProp = new LoginProperty();
    loginProp1 = new LoginProperty();
    loginProp.setServer('INAXSRV');
    loginProp.setDatabase('N_HS_Testing');
    loginProp1.setServer('INAXSRV');
    loginProp1.setDatabase('N_HS_Testing');
    conn = new ODBCConnection(loginProp);
    conn1 = new ODBCConnection(loginProp1);
    statement1  = conn.createStatement();
    statement2  = conn1.createStatement();

    perm = new SQLStatementExecutePermission("SELECT * FROM [N_HS_Testing].[dbo].[AX_LEDGERJOURNAL] where flag =0 and CENTER_ID =1 and [CREATED_DATE] >='"+'2011-05-01 00:00:00.000'+ "'and [CREATED_DATE] <='"+'2011-05-31 00:00:00.000'+"' ");
    perm.assert();
    resultSet   = statement1.executeQuery("SELECT * FROM [N_HS_Testing].[dbo].[AX_LEDGERJOURNAL] where flag =0 and CENTER_ID =1 and [CREATED_DATE] >='"+'2011-05-01 00:00:00.000'+"'and [CREATED_DATE] <='"+'2011-05-31 00:00:00.000'+"' ");
    resultSetCount = resultSet;
    progress.setCaption("Progress bar example…");
    progress.setAnimation(#AviUpdate);
    progress.setTotal(254360);
    ttsbegin;
    while (resultSet.next())
    {
        i++;
        counter++;
        LedgerJournal.LedgerGerneral_Id  = resultSet.getString(1);
        LedgerJournal.JournalNum         = resultSet.getString(2);
        LedgerJournal.JournalName        = resultSet.getString(3);
        LedgerJournal.DateTime           = resultSet.getDateTime(5);
        LedgerJournal.CenterId           = any2int(resultSet.getInt64(8));
        LedgerJournal.insert();
      //  this.Journaltransentry(LedgerJournal.JournalNum);
        sql = "update  [N_HS_Testing].[dbo].[AX_LEDGERJOURNAL] set flag =1 where flag =0  and [LEDGERGENERAL_ID] = '" + LedgerJournal.LedgerGerneral_Id + "';";
        statement2.executeUpdate(sql);
        progress.setText(strfmt("The value of i is %1", i));
        progress.setCount(i, 1);
       /* if(counter==1)
        {
            break;
        }*/
    }
    ttscommit;
    info('successfully imported');
    info(strfmt('%1',i));
    CodeAccessPermission::revertAssert();
}

No comments:

Post a Comment