This error will occur when you add new dataSource with function “addDataSource(tableNum(MyTable))” but not specify which it’s parent datasource
so example code before :
qbsInventDim = _query.addDataSource(tableNum(WMSLocation));
code after :
qbsInventDim = _query.dataSourceTable(tableNum(InventDim)).addDataSource(tableNum(WMSLocation))