我的数据表为 BDE 的,即 扩展名为 db的数据文件,数据文件为access时就可以控制,但是为DB的时候却不行,怎么办,代码如下:
with table2 do begin
if not active then open;
refresh;
setkey;
fieldbyname('姓名').asstring:=edit1.text;
gotokey;
if gotokey then begin
showmessage('你所输入的姓名已经存在!!');
abort;
end;
end;
with table2 do begin
if not active then open;
refresh;
setkey;
fieldbyname('姓名').asstring:=edit1.text;
gotokey;
if gotokey then begin
showmessage('你所输入的姓名已经存在!!');
abort;
end;
end;
if not adoquery1.eof then
showmessage('你所输入的姓名已经存在!!');
function RecordExists:boolean;
var
adsTemp:TADODataSet;
begin
adsTemp:=TADODataSet.Create;
adsTemp.Connection:=ADOConnection1;//设置连接
adsTemp.CommandText:='SELECT 1 FROM Table WHERE 主键字段='+QuotedStr(Edit1.Text)
try
adsTemp.Active:=True;
if adsTemp.RecordCount>0 then
Result:=True
else
Result:=False;
finally
adsTemp.Close;
FreeAdnNil(adsTemp);
end;
end;将ado的控件改成bde的