回 帖 发 新 帖 刷新版面

主题:在制作一个管理系统时出现的问题

#include <vcl.h>
#pragma hdrstop

#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
//---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm4::Button1Click(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------

void __fastcall TForm4::Button2Click(TObject *Sender)
{
   ADOTable1->Close();
   ADOTable1->IndexFieldNames=ComboBoxEx1->Text;
   ADOTable1->Open();
   if (!ADOTable1->FindKey(TVarRec(Edit1->Text),0))
   ShowMessage("找到相关资料");
   else
   ShowMessage("没有要查的资料");

}

提示出错:[C++ Error] Unit4.cpp(29): E2316 'FindKey' is not a member of 'TADOTable'

这是本人在制作一个管理系统时出现的问题,请教各位高手,怎么解决这个问题?

回复列表 (共5个回复)

沙发

只有从TCustomClientDataSet继承的类和TTable才有FindKey方法。        

板凳

那 么应该怎么修改代码呢?请帮忙解答一下

3 楼

if (!ADOTable1->FindKey(TVarRec(Edit1->Text),0))
改成 if (ADOTable1->Locate('字段名', Edit1->Text), TLocateOptions())

4 楼

但是我用的是ComboBoxEx控件啊,这个是下拉式的,里面的选项不止一个,如果要用字段名的话,那么一但选项改变了,怎么进行查询呢?还请楼上的指点一二。

5 楼

有没有能帮我的啊?现在出这个问题,我一直没有解决啊

我来回复

您尚未登录,请登录后再回复。点此登录或注册