report using fetch

“The data source is not embedded within a (parent) data source.”

This is the error i get while trying to fetch a record from a table in report using fetch method without using datasource or querry in AOT.

How do i solve this error

the following is the fetch method which i have written in Report

public boolean fetch()
{
CarTable carTable1,carTable2;
QueryRun qr;
QueryBuildDatasource QueryBuildDatasource1;
;
qr = new QueryRun(element);
QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CarTable));
while (qr.next())
{
if (qr.changed(tableNum(CarTable)))
{
carTable1 = queryRun.get(tableNum(CarTable));
if(carTable1)
{
element.newPage();
}
this.send(carTable1);

if(carTable1.CarBrand)
{
while select carTable1 where carTable1.CarId == carTable2.CarId
{
element.send(carTable1);
}
}
}
}
return true;
}

I want to fetch records from just 1 table …i.e cartable display on report

Is it Nav or AX?

ax 2009

First of all, you use qr variable to iterate through results and queryRun variable to get table buffer. That’s obviously wrong.

And are you aware of that the statement QueryBuildDatasource1 = element.query().dataSourceTable(tablenum(CarTable)); does nothing useful?

sorry i was unaware of it …thanks a lot now how to i iterate with help of qr?

You already iterate through query results by while (qr.next()). You need to call get() on the same object (i.e. qr, not on queryRun).

Thanks very much Martin…