web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to show SQL Data in AX quickly?

(0) ShareShare
ReportReport
Posted on by 319

Hello,

I use SQL language to get Data in Excel.

I think that is passable show in AX for user to use?

Where is quickly way to do this??

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • MYGz Profile Picture
    2,355 on at

    Yes. You can directly insert the sql query in AX table without copying it to Excel. Then you can display the table through a form.
    If you can give more details, then I might be able to suggest you a solution.

  • Hossein.K Profile Picture
    6,648 on at

    Hi ATMA-Jen,

    Can you explain more?with example.Plz

  • MYGz Profile Picture
    2,355 on at

    Also go through my answer, I wrote earlier:

    community.dynamics.com/.../303452

  • Jie G Profile Picture
    Microsoft Employee on at

    Hello,

    You can query the data from SQL Server in X++ and disply it.  

    - Reference: docs.microsoft.com/.../how-to-connect-to-an-external-database-from-x-code

    Or you can make use of EP site(actually SharePoint). Its external list feature can show the data from extenal sql database without any code required, just some comfiguration steps.

    - Reference: support.office.com/.../create-an-external-list-6e2d601d-b02f-41e7-ba87-e70297ec6665

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at
    Hi ATMA-Jen,
    For get data from excel:

    static void ImportExcel(Args _args) { SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; FileName filename; str yourParameter; str st1, st2; int row = 0 ; SysLabelEdit SysLabelEdit = new SysLabelEdit(); application = SysExcelApplication::construct(); workbooks = application.workbooks(); //specify the file path that you want to read filename = "D:\\importtest.xlsx"; try workbooks.open(filename); catch (Exception::Error) throw error("File cannot be opened."); workbook = workbooks.item(1); worksheets = workbook.worksheets(); worksheet = worksheets.itemFromNum(1); cells = worksheet.cells(); do { row++; yourParameter= cells.item(row, 1).value().bStr(); } while (row != CountOfExcelRow); application.quit(); }
  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi ATMA-Jen,
    For get data from excel and insert in table in sql server(for example TblTest):


    static void ImportExcel(Args _args) { SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; FileName filename; str yourParameter; str st1, st2; int row = 0 ;
    TblTest tblTest1; SysLabelEdit SysLabelEdit = new SysLabelEdit(); application = SysExcelApplication::construct(); workbooks = application.workbooks(); //specify the file path that you want to read filename = "D:\\importtest.xlsx"; try workbooks.open(filename); catch (Exception::Error) throw error("File cannot be opened."); workbook = workbooks.item(1); worksheets = workbook.worksheets(); worksheet = worksheets.itemFromNum(1); cells = worksheet.cells(); do { row++; yourParameter= cells.item(row, 1).value().bStr();
             tblTest1.field1 = yourParameter;
             tblTest1.insert();
    } while (row != CountOfExcelRow); application.quit(); }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans