void __fastcall TForm_DeptInformation::CalculateChild()
{
AnsiString str1,str2;
Variant a,b;
str1= " select count(e_id) as aa from employees_info where dept_id ="+IntToStr(nDeptID);
DataModule1->DataTranslate1->ReturnRecordset(str1,a);
TADOQuery *ado = new TADOQuery((TComponent*)NULL);
ado->Recordset = (_di_IUnknown)a;
nEmpCount = ado->FieldByName("aa")->AsInteger;
str2= " select count(dept_id) as bb from departments where parent ="+IntToStr(nDeptID);
DataModule1->DataTranslate1->ReturnRecordset(str2,b);
ado->Recordset = (_di_IUnknown)b;
nChildDeptCount = ado->FieldByName("bb")->AsInteger;
}
这是我的一个例子函数,请笑纳。