看看下面的编码有什莫错误吗?

cococola2002 2003-10-18 02:33:53
var
s:string;
opt:TLocateOptions;
begin
with table1 do
begin
opt:=[loPartialKey];
locate('Name',edit1.Text,opt);
s:=table1.FieldValues['PerNum'];
end;
end;
编译的时候没有错误,不过s的值一直为空,不知道是怎麽回事?赐教!
...全文
29 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhoutian618 2003-10-18
  • 打赏
  • 举报
回复
var
s:string;
opt:TLocateOptions;
begin
with table1 do
begin
opt:=[loPartialKey];
if locate('Name',edit1.Text,[]) then//!!!!!
s:=table1.FieldValues['PerNum']//少用这种方式,用Table1.FieldByName(l..
else
ShowMessage('定位不成功');
end;
end;
angle097113 2003-10-18
  • 打赏
  • 举报
回复
Var
s: String;
opt: TLocateOptions;
Begin
With ADOquery1 Do
Begin
opt := [loPartialKey];
locate('mingcheng', Edit1.Text, opt);
s := ADOQuery1.FieldValues['Mingcheng'];
Label1.Caption := s;
End;
End;
我试过 没有问题的呀就算是没有匹配的数据 也会显示第一条数据的 楼主再看看吧
47522341 2003-10-18
  • 打赏
  • 举报
回复
将locate一句改成:
lacate('name',trim(edit1.text),[]);
如果还有错误就是你表的链接有问题;了;

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧