The solution is to set SQL parameter type just before opening the query:
Query_Limit->Close();
Query_Limit->Open();
// ID param
TParam *param = Query_LimitDetail->Params->Items[0];
param->DataType = ftInteger;
Query_LimitDetail->Close();
Query_LimitDetail->Open();
Alternative and more universal solution is to set parameter type in OnBeforeOpen event handler like this:
__fastcall MyDataModule::MyDataModule(TComponent *Owner) :
TDataModule(Owner)
{
...
Query_LimitDetail->BeforeOpen = Query_LimitDetail_OnBeforeOpen;
...
}
void __fastcall MyDataModule::Query_LimitDetailBeforeOpen(TDataSet *DataSet)
{
if (Query_LimitDetail->Params->Count == 0)
{
return;
}
// ID param
TParam *param = Query_LimitDetail->Params->Items[0];
param->DataType = ftInteger;
}
It is also neccessary to link column in master table (specified in MasterFields
property) to column in detail table:
Query_LimitDetail->IndexFieldNames = L"LIMIT_ID";