Windows Programming/Delphi 6/7

Delphi6/7 TADOQuery - 기본적인 조회 코드 조각

denisOh 2010. 9. 13. 02:25

보통 ADOQuery를 사용하여 많은 조회 쿼리를 수행한다.
아래는 ADOQuery를 사용할 때 쓰이는 기본적인 코드 조각이다.

  with ADOQuery1 do begin
    if Active then Close;
    SQL.Clear;
    SQL.Text := 'SELECT * FROM tablename';
                   + ' WHERE name = :NAME;
    Parameters.ParamByName('NAME').Value := 'ojh';
    Open;
    while not Eof do begin
      // FieldByName('title').AsString;
      // FieldByName('id').AsInteger;
      Next;
    end;
    Close;
  end;