Search code examples
axaptax++dynamics-ax-2012

Select statement string in form method in Dynamics AX 2012 r2


There is a code in Form's init method:

strQuery = strFmt("select * from %1", something);

And it gives BP warning that Method contains text constant: select * from %1

Should I create a label from it or should I define a local macro? Which is more advised?

Also is it ok on forms this kind of select statements?

Thanks.


Solution

  • You should use single quotes. SQL statements should not be stored in labels.

    And no, it is not okay, direct SQL in forms is a very bad idea.

    If you have to access external databases with direct SQL, make a class to provide the data.