with CustTable do Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);或者procedure TForm1.Button1Click(Sender: TObject);var V: Variant; C: Integer; A: String; begin V := Table1.Lookup('Company;State', VarArrayOf(['Blue Sports', 'OR']), 'CustNo;Addr1'); if not (VarType(V) in [varNull]) then begin C := V[0]; A := V[1]; ShowMessage(IntToStr(C) + #10 + A); end else ShowMessage('Search unsuccessful!');end;或者withTable1 dobegin { This is the safe way to change 'CustNo' field } FindField('CustNo').AsString := '1234'; { This is *not* the safe way to change 'CustNo' field } Fields[0].AsString := '1234';end;
showmessage('没找到!')
或者
ADOQuery1.Locate(FieldName,LocateValue,[loCaseInsensitive]);
Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P', '408-431-1000']), [loPartialKey]);或者procedure TForm1.Button1Click(Sender: TObject);var
V: Variant;
C: Integer;
A: String;
begin
V := Table1.Lookup('Company;State',
VarArrayOf(['Blue Sports', 'OR']),
'CustNo;Addr1');
if not (VarType(V) in [varNull]) then begin
C := V[0];
A := V[1];
ShowMessage(IntToStr(C) + #10 + A);
end
else
ShowMessage('Search unsuccessful!');end;或者withTable1 dobegin
{ This is the safe way to change 'CustNo' field }
FindField('CustNo').AsString := '1234';
{ This is *not* the safe way to change 'CustNo' field }
Fields[0].AsString := '1234';end;