Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Wednesday, July 7, 2021

Fetch Data from direct SQL Queries in ax 2012 d365fo

 Fetch Data from direct SQL Queries



        Connection  connection;

        Statement   statement;

        str         sql;

        ResultSet   resultSet;

        SqlStatementExecutePermission   perm;


        //sql =  "SELECT COUNT(*) as [NumOfCombinations] FROM " + "( " + "select MyName, MyValue " + "from tab1 " + strFmt("where DATAAREAID = '%1' ",curext()) + "group by MyName, MyValue" + ") a";

        sql =  strFmt("select * from taxtrans where TRANSDATE between CONVERT(date, '%1') and CONVERT(date, '%2')", datetime2Str(DateTimeUtil::newDateTime(fromDateValue,0)), datetime2Str(DateTimeUtil::newDateTime(toDateValue,0)));


        connection = new connection();


        perm = new SqlStatementExecutePermission(sql);


        perm.assert();


        statement = connection.createStatement();


        resultSet = statement.executeQuery(sql);


        while (resultSet.next())


No comments:

Post a Comment