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

DELPHI基礎教程:數據訪問部件的應用及編程(一)[2]

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

  程序清單

  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為數據集部件提供了相應的方法用於其中的數據維護這些方法如表所示

[]  []  []  []  


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