TempDB Table in form - multiple linking physical instance problem


i have this code there i try to init table data on checkbox clicked method multiple times but i get an : Cannot execute the required database operation.
The method is only applicable to TempDB table variables that are not linked to existing physical table instance error

how to solve it that i could link if after checkbox clicked method there i fill the data into the temporary table ?

public void INSfillCostCentersListPageTmp()
LedgerTrialBalanceListPageTmp ledgerTrialBalanceListPageTmp;
QueryBuildDataSource qbds;
Common common;
str 60 dimensionValue;
INSAccountCenters1 iNSAccountCenters1Table;
INSAccountCenters2 iNSAccountCenters2Table;
INSAccountCenters3 iNSAccountCenters3Table;

delete_from iNSCostCentersListPageTmpTable;

while select * from iNSAccountCenters1Table
iNSCostCentersListPageTmpTable.DisplayValue = iNSAccountCenters1Table.Value;

select sum(AmountCredit), sum(AmountDebit) from LedgerTrialBalanceTmp where LedgerTrialBalanceTmp.DimensionValues[2] == iNSAccountCenters1Table.Value && LedgerTrialBalanceTmp.DimensionValues[1] == iNSAccountCenters1Table.MainAccountId;

iNSCostCentersListPageTmpTable.SalesTotal = LedgerTrialBalanceTmp.AmountCredit - LedgerTrialBalanceTmp.AmountDebit;

total = total + iNSCostCentersListPageTmpTable.SalesTotal;


INSCostCentersListPageTmp.linkPhysicalTableInstance(iNSCostCentersListPageTmpTable); // INS Raimondas - INS_SalesFigures_52673 8/23/2018

this is the init method

public void init()

INSCostCentersListPageTmp.setTmpData(iNSCostCentersListPageTmpTable); // INS Raimondas - INS_SalesFigures_52673 8/23/2018

INSCostCentersListPageTmp.linkPhysicalTableInstance(iNSCostCentersListPageTmpTable); // INS Raimondas - INS_SalesFigures_52673 8/23/2018


Is that a tempDB or InMemory table?I think its InMemory, if so use setTmpData

Use this only in case if TempDB table.

For more details about temp tables, blogs.msdn.microsoft.com/…/