数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

DELPHI基础教程:SQL编程(二)[4]


发布日期:2019年01月19日
 
DELPHI基础教程:SQL编程(二)[4]

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游戏开发实践指南

[] [] [] []

               

上一篇:DELPHI基础教程:SQL编程(一)[1]

下一篇:DELPHI基础教程:SQL编程(二)[3]