Question

This is how my db components are connected in program:

enter image description here

The datatypes of components are (first row, from left to right): TDBGrid, TDataSource, TClientDataSet, TDataSetProvider, TSQLQuery, TSQLConnection. Second row is analogous to first row.

Client data set Query_LimitDetail is linked to master data source through properties MasterSource and MasterFields. Their values are as follows:

Query_LimitDetail->MasterSource = DataSource_Limit;
Query_LimitDetail->MasterFields = L"ID";

SQL command assigned to client data sets are:

select * from LIMIT order by NAME
select * from LIMITDETAIL where LIMIT_ID = :ID order by ACCUR

This is how i open queries:

Query_Limit->Open();
Query_LimitDetail->Open();

When trying to open detail query, program throws following error:

dbExpress driver does not support the TDBXTypes.UNKNOWN data type. Vendor error message: unknown ISC error 0

Is there something I didnt make correctly?

Was it helpful?

Solution

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";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top