cannot access an inactive scope
bool __fastcall ComplexFd(int tag,TDBGridEh *Gd,AnsiString &sqlstr,bool &SelAll,bool AllField,bool visID)
{
bool Ret = false;
Application->CreateForm(__classid(TfmComplexFd), &fmComplexFd);
try
{
fmComplexFd->CmbFieldName->Items->Clear();
fmComplexFd->TAG = tag;
fmComplexFd->edtFrom->Enabled = visID;
fmComplexFd->edtTo->Enabled = visID;
ShowMessage(Gd->Columns->Items[0]->Field->DataType);
for (int i = 0; i < Gd->Columns->Count; i++)
{
if((Gd->Columns->Items[i]->Field->DataType != 16)
&& Gd->Columns->Items[i]->FieldName != "EDocNO")
{
fmComplexFd->CmbFieldName->Items->Add(Gd->Columns->Items[i]->Title->Caption); fmComplexFd->lsSource->AddObject(Gd->Columns->Items[i]->FieldName,(TObject*)Gd->Columns->Items[i]->Field->DataType);
}
}
if(fmComplexFd->ShowModal() == mrOk)
{
sqlstr = fmComplexFd->ReturnSQL;
SelAll = fmComplexFd->SelAll;
Ret = true;
}
}
__finally
{
delete fmComplexFd;
}
return Ret;
}
我用ShowMessage去测试,访问Gd->Columns->Items[0]->Field->DataType者一句出错,错误信息是E2208 cannot access an inactive scope 编译不报错,运行才报错。请教大神这是什么原因,我是菜鸟,谢谢了
[解决办法]
DBGridEh关联的数据集是否处于打开状态?
[解决办法]
DataSource2->DataSet->Fields->Fields->Count
Columns->Count
名字记不清了,大概是这两个属性,你看看是多少,是不是0