熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Delphi編程 >> 正文

DELPHI基礎教程:SQL編程(二)[4]

2013-11-23 17:49:08  來源: Delphi編程 

  begin

  ScreenCursor := crHourglass;

  if QueryActive then QueryClose;

  QueryDatabaseName := strAlias; {set the alias the query poitns to}

  QuerySQLclear; { empty existing SQL in the query }

  QuerySQLAdd(strQuery) { add query string to query object }

  QueryActive := True; { try to run the query }

  ScreenCursor := crDefault;

  if QueryActive then

  begin

  { If the query didnt return any records theres no point in

  displaying the form In that event raise an exception }

  if QueryRecordCount < then

  raise Exceptioncreate(No records matched your criteria

  Please try again

  { write a message to the browse forms status line }

  if strField = then

  PanelCaption := Now showing all records from + strTable

  +

  else

  PanelCaption := Now showing + strTable + where + strField

  + contains values equal to + strValue + ;

  { show the form }

  ShowModal;

  end;

  end;

  finally

  frmQueryFree;

  end;

  end;

  end

  unit RSLTFORM;

  interface

  uses

  SysUtils Windows Messages Classes Graphics Controls StdCtrls DB

  Forms DBCtrls DBGrids DBTables Buttons Grids ExtCtrls Dialogs;

  type

  TResultForm = class(TForm)

  DBGrid: TDBGrid;

  DBNavigator: TDBNavigator;

  Panel: TPanel;

  DataSource: TDataSource;

  Panel: TPanel;

  Panel: TPanel;

  Query: TQuery;

  SpeedButton: TSpeedButton;

  Panel: TPanel;

  SpeedButton: TSpeedButton;

  procedure SpeedButtonClick(Sender: TObject)

  procedure SpeedButtonClick(Sender: TObject)

  end;

  var

  ResultForm: TResultForm;

  implementation

  {$R *DFM}

  procedure TResultFormSpeedButtonClick(Sender: TObject)

  begin

  Close;

  end;

  procedure TResultFormSpeedButtonClick(Sender: TObject)

  var

  strText: string; { Variable to hold display text }

  iCounter: Integer; { Loop counter variable }

  begin

  { Build a string containing the query }

  strText := ;

  for iCounter := to QuerySQLCount do

  strText := strText + QuerySQL[iCounter];

  { Display the query text }

  MessageDlg(The underlying query is: + # + # + strText

  mtInformation [mbOK]

  end;

  end

  返回目錄DELPHI基礎教程

       編輯推薦

       Java程序設計培訓視頻教程

       JEE高級框架實戰培訓視頻教程

  Visual C++音頻/視頻技術開發與實戰

  Oracle索引技術

  ORACLEG數據庫開發優化指南

  Java程序性能優化讓你的Java程序更快更穩定

  C嵌入式編程設計模式

  Android游戲開發實踐指南

[]  []  []  []  


From:http://tw.wingwit.com/Article/program/Delphi/201311/25143.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.