strTemp:='select customer_no' + 'from customer_file ';
with adoquery1 do 
begin
     CursorLocation:=clUseServer;
     CursorType:=ctOpenForwardOnly;
     LockType:=ltReadOnly;
     Connection:=cnnOracle;
     CacheSize:=200;
     CommandTimeout:=60;
     SQL.Clear;
     SQL.Add(strTemp);
     DisableControls;
     Active:=true;
end;
请问我想知道customer_no='0001'的记录存在否怎么写?
我这样adoquery1.FindField('customer_no').Value='0001' 找不到,但是
明明有这条记录的?请帮帮我。

解决方案 »

  1.   

    strTemp:='select customer_no from customer_file where customer_no='+''''+'0001'+'''';
    with adoquery1 do 
    begin
         DisableControls;
         Close;
         SQL.Clear;
         SQL.Add(strTemp);
         Active:=true;
         EnableControls;
    end;
      

  2.   


    在delphi6以上版本用:adoquery1.Parameters.ParamByName('customer_no').Value='0001'在delphi6以下版本用:
    adoquery1.parambyname('customer_no').asstring='0001'
      

  3.   

    strTemp:='select customer_no from customer_file where customer_no=:customer_no';
    with adoquery1 do 
    begin
         CursorLocation:=clUseServer;
         CursorType:=ctOpenForwardOnly;
         LockType:=ltReadOnly;
         Connection:=cnnOracle;
         CacheSize:=200;
         CommandTimeout:=60;
         Close; 
         SQL.Clear;
         SQL.Add(strTemp);
         Parameters[0].value := '0001'
         DisableControls;
         Active:=true;
    end;
      

  4.   

    strTemp:='select customer_no' + 'from customer_file where customer_no'
      +'=:no';
    ....................
    params[0].value:= '0001'
      

  5.   

    if not ADOQuery1.Locate(locFieldName, locFieldValue, [])then
       ShowMessage('紀錄沒有找到.');
      

  6.   

    strTemp:='select customer_no from customer_file where customer_no=:customer_no';
    with adoquery1 do 
    begin
         CursorLocation:=clUseServer;
         CursorType:=ctOpenForwardOnly;
         LockType:=ltReadOnly;
         Connection:=cnnOracle;
         CacheSize:=200;
         CommandTimeout:=60;
         Close; 
         SQL.Clear;
         SQL.Add(strTemp);
         Parameters[0].values := '0001'
         DisableControls;
         Active:=true;
    end;
      

  7.   

    adoquery1.Locate('customer_no','0001',[loPartialKey]);
      

  8.   

    1.如果重新查询这条记录用SQL语句
    2。如果在现有的记录中查找用LOCATE方法
      

  9.   

    strTemp:='select customer_no from customer_file where customer_no=:customer_no';
    with adoquery1 do 
    begin
         CursorLocation:=clUseServer;
         CursorType:=ctOpenForwardOnly;
         LockType:=ltReadOnly;
         Connection:=cnnOracle;
         CacheSize:=200;
         CommandTimeout:=60;
         Close; 
         SQL.Clear;
         SQL.Add(strTemp);
         Parameters[0].value := '0001'
         DisableControls;
         Active:=true;
    end;
      

  10.   

    strTemp:='select customer_no' + 'from customer_file ';
    with adoquery1 do 
    begin
         CursorLocation:=clUseServer;
         CursorType:=ctOpenForwardOnly;
         LockType:=ltReadOnly;
         Connection:=cnnOracle;
         CacheSize:=200;
         CommandTimeout:=60;
         SQL.Clear;
         SQL.Add(strTemp);
         DisableControls;
         Active:=true;
    while not eof do
    begin
    if adoquery1.fieldbyname('coustomer_no').asstring='0001' then
    begin
    showmessage('有这条纪录');
    break;
    end
    else
    next;
    end;
    end;
    这样你试试看!
      

  11.   

    adoquery1.sql.clear;
    adoquery1.sql.add('select * from table where customer_no='0001');
    adoquery1.sql.open;  
    if eof then
      no
      

  12.   

    strTemp:='select customer_no from customer_file where customer_no=:customer_no';
    with adoquery1 do 
    begin
         CursorLocation:=clUseServer;
         CursorType:=ctOpenForwardOnly;
         LockType:=ltReadOnly;
         Connection:=cnnOracle;
         CacheSize:=200;
         CommandTimeout:=60;
         Close; 
         SQL.Clear;
         SQL.Add(strTemp);
         Parameters[0].values := '0001'
         DisableControls;
         Active:=true;
    end;
      

  13.   

    我是要再一个现有的Record集合中找记录,怎么做?