其他语言

位置:IT落伍者 >> 其他语言 >> 浏览文章

DELPHI基础教程:数据访问部件的应用及编程(一)[2]


发布日期:2020年09月03日
 
DELPHI基础教程:数据访问部件的应用及编程(一)[2]

程序清单

unit unit;

interface

uses

SysUtils Windows Messages Classes Graphics Controls

Forms Dialogs StdCtrls DB DBTables Buttons ComCtrls Tabnotbk;

type

TQueryForm = class(TForm)

BitBtn: TBitBtn;

DataSource: TDataSource;

Table: TTable;

GroupBox: TGroupBox;

CheckBox: TCheckBox;

CheckBox: TCheckBox;

PageControl: TPageControl;

TabSheet: TTabSheet;

Label: TLabel;

Label: TLabel;

Label: TLabel;

ListBox: TListBox;

ListBox: TListBox;

ListBox: TListBox;

TabSheet: TTabSheet;

Memo: TMemo;

procedure FormCreate(Sender: TObject)

procedure ListBoxClick(Sender: TObject)

procedure ListBoxClick(Sender: TObject)

end;

var

QueryForm: TQueryForm;

implementation

{$R *DFM}

uses RSLTFORM;

procedure TQueryFormFormCreate(Sender: TObject)

begin

ScreenCursor := crHourglass;

{ Populate the alias list }

with ListBox do

begin

ItemsClear;

SessionGetAliasNames(Items)

end;

{ Make sure there are aliases defined }

ScreenCursor := crDefault;

if ListBoxItemsCount < then

MessageDlg( There are no database aliases currently defined You +

need at least one alias to use this demonstration

mtError [mbOK]

end;

procedure TQueryFormListBoxClick(Sender: TObject)

var

strValue: string; { Holds the alias selected by the user }

bIsLocal: Boolean; { Indicates whether or not an alias is local }

slParams: TStringList; { Holds the parameters of the selected alias }

iCounter: Integer; { An integer counter variable for loops}

begin

{ Determine the alias name selected by the user }

with ListBox do

strValue := ItemsStrings[ItemIndex];

{ Get the names of the tables in the alias and put them in the

appropriate list box making sure the users choices are reflected

in the list }

ListBoxItemsClear;

SessionGetTableNames(strValue { alias to enumerate }

{ pattern to match }

数据集中的数据维护

数据集中的数据维护主要包括数据记录的修改插入和删除Delphi为数据集部件提供了相应的方法用于其中的数据维护这些方法如表所示

[] [] [] []

               

上一篇:DELPHI基础教程:数据访问部件的应用及编程(一)[3]

下一篇:DELPHI基础教程:数据访问部件的应用及编程(一)[1]