none
Migration AX 4.0 to AX 2009 RRS feed

  • Вопрос

  • I had one button in AX 4.0 on my customized form as "Import Excel" The code written on its click event was as below

    void clicked()

    {

    CCADOConnection adoexcel = new CCADOConnection();

    CCAdoxCatalog adoCatalog = new CCAdoxCatalog();

    COM adoxCatalog = new COM('ADOX.Catalog');

    CCADORecordSet adoRecordSet = new CCADORecordSet();

    str connectStr, valueStr;

    CCADOFields adoFields;

    comvariant var1;

    CCADOField adoField;

    int i, j, k;

    ;

    if(strlen(strrtrim(BranchCode.valueStr())) == 0)

    {

    warning("First select Branch Code");

    }

    else

    {

    validate = false;

    // Deleting all rows and columns

    EmpDetlTable.deleteRows(2, EmpDetlTable.rows() - 1);

    connectStr = strfmt("Provider = Microsoft.Jet.OLEDB.4.0; Data Source=%1; Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'", OpenFile.valueStr());

    adoexcel.ConnectionString(connectStr);

    adoexcel.open();

    adoxCatalog.activeConnection(adoexcel.connection());

    adoCatalog.adoxCatalog(adoxCatalog);

    adoRecordSet.open(@"SELECT * FROM [SHEET1$]", adoexcel);

    adoFields = adoRecordSet.fields();

    if(adoFields.count() != EmpDetlTable.columns())

    {

    EmpDetlTable.deleteCols(adoFields.count(), EmpDetlTable.columns() - adoFields.count());

    }

    j = 1; k = 2;

    while (! adoRecordSet.EOF())

    {

    EmpDetlTable.insertRows(j,1);

    for (i = 0; i < adoFields.count(); i++)

    {

    adoField = adoFields.itemIdx(i);

    valueStr = adoField.value();

    if(i==0)

    {

    if(!element.isEmployee(valuestr))

    warning('Invalid or duplication of employee code"' + valuestr + '"');

    }

    if(i>0)

    element.isNumeric(valuestr);

    EmpDetlTable.cell(i+1, j+1).data(valueStr);

    k++;

    }

    adoRecordSet.moveNext();

    k = 1;

    j ++;

    }

    validate = true;

    EmpDetlTable.update();

    }

    super();

    }




    But many of the system classes are deleted in AX 2009 so can any tell me the exact replacement of the code. I have migrated my entire AX 4.0 project to AX 2009 except this code which I didnt find any replacement for it