«á¤@­¶
«e¤@­¶
¦^¥Ø¿ý
¦^­º­¶
²Ä¤Q¤­³¹¡@¼Æ¾Ú¦s¨ú³¡¥óªºÀ³¥Î¤Îµ{¦¡³]­p¡]¤@¡^

    ¦b³o¤@³¹ùاڭ̥D­n¤¶²ÐDelphiªº¼Æ¾Ú¦s¨ú³¡¥óªº¼h¦¸µ²ºc¡B ¦h³¡¥ó¤§¶¡ªºÃö«Y¡B³¡¥óªºÄÝ©Ê¡B¤èªk¡B¨Æ¥ó¥H¤Î¦U³¡¥óªºÀ³¥Î¡C³o¨Ç³¡¥ó¥]¬A¡G

¡´ TSession³¡¥ó

¡´ ¼Æ¾Ú¶°³¡¥ó(TTable©MTQuery)

¡´ TDatasource³¡¥ó

¡´ Äæ¦ìª«¥óTField

¡´ Äæ¦ì½s¿è¾¹ªº¨Ï¥Î

¡´ TReport³¡¥ó©MTBatchMove³¡¥ó

§Ú­Ì¹ï³o¨Ç³¡¥óªºÄÝ©Ê¡B¤èªk©M¨Æ¥ó¶i¦æ¤@¯ë©Êªº´y­z¡AŪªÌ¦b¹ê»Ú¨Ï¥ÎDelphi¶}µoÀ³¥Îµ{¦¡®É¡AÁÙ¥i¥H³q¹L³s½u»²§U±Ô­zÀò±o¦³Ãö³¡¥ó§ó¸Ô²Óªº¸ê°T¡C¡@

15.1 Delphi¼Æ¾Ú¦s¨ú³¡¥óªº¼h¦¸µ²ºc¡@

        Delphi´£¨Ñ¤F±j¤jªº¶}µo¸ê®Æ®wÀ³¥Îµ{¦¡ªº¯à¤O¡A¥¦µ¹¥Î¤á´£¨Ñ¤F¤j¶qªº¼Æ¾Ú¦s¨ú³¡¥ó¡C¥H¤è«Kµ{¦¡³]­p¤H­û¶}µo¸ê®Æ®wÀ³¥Îµ{¦¡¡C³o¨Ç³¡¥ó¤¤¡A¦³¨Ç³¡¥óÄ~©Ó¤F¥t¤@¨Ç³¡¥óªºÄÝ©Ê¡B¤èªk©M¨Æ¥ó¡A¤]´N¬O»¡¦h³¡¥ó¤§¶¡¦s¦bµÛÄ~©Ó©M³QÄ~©ÓªºÃö«Y¡A¦U³¡¥óªº³oºØÃöÁp«Kºc¦¨¤F¤@­Ó¼h¦¸µ²ºc¡@

¹Ï15.1 Delphi¼Æ¾Ú¦s¨ú³¡¥óªº¼h¦¸µ²ºc¡@

TSession¬O¥þ§½©Êªº³¡¥ó¡A¦bÀ³¥Îµ{¦¡°õ¦æ®É¡A¥¦¦Û°Ê¦a«Ø¥ß¡A¦b³]­p¶¥¬q©M°õ¦æ¹Lµ{¤¤¥¦¬O¤@­Ó¤£¥i¨£ªº³¡¥ó¡C

TDatabase³¡¥ó¬O¬°¶}µo¥Î¤á/¦øªA¾¹¸ê®Æ®wÀ³¥Îµ{¦¡®É¡A³]©wµn¤Jªº¸ê®Æ®wªº¦³Ãö°Ñ¼Æªº¡A¥¦¦b¼Æ¾Ú¦s¨ú³¡¥ó­¶¤W¡C

TDataset³¡¥ó¬O¤£¥i¨£ªº¡ATTable©MTQuery³¡¥ó¬O¥Ñ¥¦¬£¥Í¦Ó¨Óªº¡A³o¨â­Ó³¡¥ó¤@¯ë³QºÙ¬°¼Æ¾Ú¶°³¡¥ó¡A¥¦­Ì¦b¼Æ¾Ú¦s¨ú³¡¥ó­¶¤W¡C

TDatasource³¡¥ó¬O³s±µ¼Æ¾Ú¶°³¡¥ó©M¼Æ¾ÚÂsÄý³¡¥óªº¾ô¼Ù¡A¥¦¦b¼Æ¾Ú¦s¨ú³¡¥ó­¶¤W¡C

TFields³¡¥ó¹ïÀ³©ó¸ê®Æ®wªí¤¤ªº¹ê»ÚÄæ¦ì¡A¥¦¬J¥i¥H¦bÀ³¥Îµ{¦¡ªº°õ¦æ¹Lµ{¤¤°ÊºA¦a²£¥Í¤]¥i¥H¦bµ{¦¡³]­p¶¥¬q¥ÎÄæ¦ì½s¿è¾¹«Ø¥ß¡C¥¦¬O¤£¥i¨£ªº³¡¥ó¡A¦bµ{¦¡¤¤§Ú­Ì¥i¥H³q¹LTField³¡¥ó¨Ó¦s¨ú¸ê®Æ®w°O¿ýªº¦U­ÓÄæ¦ì­È¡C¡@

15.2 Tsession³¡¥ó¤Î¨äÀ³¥Î¡@

TSession³¡¥ó¤@¯ë¥Î±o¸û¤Ö¡A¦ý¥¦¹ï©ó¤@¨Ç¯S®íªºÀ³¥Î¬O«Ü¦³¥Îªº¡A¦b¨C¤@­Ó¸ê®Æ®wÀ³¥Îµ{¦¡°õ¦æ®ÉDelphi¦Û°Ê¦a«Ø¥ß¤@­ÓTSession³¡¥ó¡Cµ{¦¡³]­p¤H¬J¤£¯à¬Ý¨£¸Ó³¡¥ó¤]¤£¯àÅã¥Ü¦a«Ø¥ß¤@­ÓTSession ³¡¥ó¡A¦ý¬O§Ú­Ì¥i¥H¦bÀ³¥Îµ{¦¡¤¤¥þ§½©Ê¦a¨Ï¥ÎTSession³¡¥óªºÄÝ©Ê¡B¤èªk¡C¡@

15.2.1 TSession³¡¥óªº­«­nÄݩʤΧ@¥Î¡@

TSession³¡¥óªº³\¦h­«­nÄݩʬO¥Î©ó±±¨î¸ê®Æ®wÀ³¥Îµ{¦¡»P¸ê®Æ®wªº³s±µªº¡A¦b¤@­ÓÀ³¥Îµ{¦¡¤¤¡A¥i¥H¥þ§½©Ê¦a³]©wTSessionªº¦³ÃöÄÝ©Ê­È¡A¹ï»P¤§¬Û³s±µªººÏºÐ¤Wªº¸ê®Æ®w¶i¦æ±±¨î¡CTSession³¡¥ó¥D­n¦³¤U¦CÄÝ©Ê¡G

DatabaseÄÝ©Ê¡G¬OTSession¤¤¥i¥H¶i¦æ³s±µªº©Ò¦³¸ê®Æ®wªº¸ê®Æ®w¦W¦r²M³æ¡A³o¨Ç¸ê®Æ®wªº¦W¦r±`±`¬O¹ê»Ú¸ê®Æ®wªº§O¦W¡A¥]¬A¸ê®Æ®wªº¸ô®|¡B¥Î¤á¦W¡B¥Î¤áµn¤J±K½Xµ¥°Ñ¼Æ¡C

DatabaseCountÄÝ©Ê¡G¬OTSession¤¤¥i¥H¶i¦æ³s±µªº©Ò¦³¸ê®Æ®wªº¼Æ¶q¡A¥¦¬O¤@­Ó¾ã¼Æ¡C

KeepCounnectionsÄÝ©Ê¡G¬O¤@­Ó¥¬º¸«¬ÄÝ©Ê¡A¥Î¥¦±Ô­zÀ³¥Îµ{¦¡¬O§_«O«ù»P¤@­Ó«D¬¡°Ê¸ê®Æ®wªº³s±µ¡C¦]¬°¹ï©ó¤@­Ó¸ê®Æ®w¡A·í¸Ó¸ê®Æ®w¤¤¨S¦³¬ÛÀ³ªº¼Æ¾Ú¶°³¡¥ó(TTable©ÎTQuery)³Q¥´¶}®É¡A¸Ó¸ê®Æ®w±N¦Û°Ê¦aÅܦ¨«D¬¡°Êªº¸ê®Æ®w¡C¯Ê¬Ù±¡ªp¤U¡AKeePcounnectionsªº­È¬OTrue¡A´N¬O»¡À³¥Îµ{¦¡Á`¬O«O«ùµÛ»P¸ê®Æ®wªº³s±µ¡A §Y¨Ï¸ê®Æ®wÅܦ¨¤F«D¬¡°Êªº¸ê®Æ®w®É¡A¤]¬O¦p¦¹¡C¦pªG±NKeepConnectionsÄݩʳ]©w¦¨False¡A¨º»ò·í¸ê®Æ®w¥Ñ¬¡°Êª¬ºAÅܦ¨«D¬¡°Êª¬ºA®É¡AÀ³¥Îµ{¦¡»P¸Ó¸ê®Æ®wªº³s±µ¤]ÀH¤§¤¤Â_¡C

NetFileDirÄÝ©Ê¡G±Ô­zBDEºô¸ô±±¨î¤å¥óªº¸ô®|¦W¡C

PrivateDirÄÝ©Ê¡G±Ô­z¦s¨úÁ{®É¤å¥óªº¸ô®|¦W¡C¡@

15.2.2 TSession³¡¥óªº¤èªk¡G¡@

TSession³¡¥ó¤¤ªº¤j³¡¤À¤èªk¬O¥Î©ó¦V¥Î¤á´£¨Ñ»PÀ³¥Îµ{¦¡¬Û³s±µªº¸ê®Æ®wªº¸ê°T¡A¦p¸ê®Æ®wªº¦W¦r¤Î§O¦W¡A¸ê®Æ®w¤¤ªºªí¦W¥H¤Î¸ê®Æ®w¤ÞÀºBDEªº¦³Ãö°Ñ¼Æµ¥¡A¦b³]­p¸ê®Æ®wÀ³¥Îµ{¦¡®É¡A·Q­nÀò¨ú¦³Ãö¸ê®Æ®wªº¸ê°T¡A©I¥sTSession³¡¥óªº¤U¦C¤èªk¡A ±N·|¤j¤j²¤Æµ{¦¡ªº³]­p¡C

GetAliasNames¤èªk¡G©I¥s¸Ó¤èªk¡A§Ú­Ì¥i¥HÀò±o¸ê®Æ®w¤ÞÀºBDE¤¤©w¸qªº¸ê®Æ®w§O¦W¡C

GetAliasParams¤èªk¡G¸Ó¤èªk¥D­n¥Î©óÀò¨ú§Ú­Ì¦bBDE¤¤©w¸q¸ê®Æ®w§O¦W®É©Ò±Ô­zªº°Ñ¼Æ­È¡A¦pBDE©Ò¦bªº¥Ø¿ý¸ô®|¥H¤Î¹ê»Ú¼Ðñµ¥¡C

GetDatabaseNames ¤èªk¡G©I¥s¸Ó¤èªk¥i¥H»²§U±Ô­z§Ú­ÌÀò±o¥Ø«eÀ³¥Îµ{¦¡¥i¥H¶i¦æ³s±µªº©Ò¦³¸ê®Æ®wªº¦W¦r¡A¸ê®Æ®wªº¦W¦r¬O¥Î¤á¨Ï¥ÎBDE¤u¨ã©w¸qªº¹ê»Ú¸ê®Æ®wªº§O¦W¡C

GetDriverNames¤èªk¡G¸ê®Æ®w¤ÞÀºBDE¥i¥H»P¦hºØ¸ê®Æ®wºÞ²z¨t²Î¬Û³s±µ¡A¦p¥Î¤á/¦øªA¾¹¸ê®Æ®wºÞ²z¨t²ÎOracle¡BSybase¥H¤Î¥»¦a¸ê®Æ®wºÞ²z¨t²ÎdBASE,Paradoxµ¥¡ABDE»P¨C¤@ºØ¸ê®Æ®wºÞ²z¨t²Î¶i¦æ³s±µ®É¡A³£¦³¬ÛÀ³ªºÅX°Êµ{¦¡¡A¦Ó¥B³o¨ÇÅX°Êµ{¦¡³£¥i¥H¿ï¾Ü¦a¸Ë³]¡C³q¹L©I¥sGetDriverNames¤èªk¡C§Ú­Ì¥i¥HÀò±o¥Ø«eBDE¸Ë³]ªº¸ê®Æ®wÅX°Êµ{¦¡ªº¦W¦r¡C

GetDriverParams¤èªk¡GBDEªº¸ê®Æ®wÅX°Êµ{¦¡¤¤¥]§tµÛ¦h­Ó°Ñ¼Æ¡A¦p¤ä´©ªº¥Á±Ú»y¨¥¡BDBMSªºª©¥»¸¹¡B¤å¥ó¶ô¤j¤pµ¥¡A¹ï©ó¦øªA¾¹¤WªºDBMS¡AÁÙ¦³¸ê®Æ®w¦øªA¾¹ªº¦W¦rµ¥µ¥¡C

GetTableNames¤èªk¡G¦]¬°¨C¤@­Ó¸ê®Æ®w³£¬O¥Ñ¦h­Ó¸ê®Æ®wªí¸s¸s²Õ¦¨ªº¡A§Ú­Ì³q¹L±Ô­z¸ê®Æ®w¦W¡AµM«á©I¥sGetTableNames¤èªk¡A«K¥i¥HÀò±o¸Ó¸ê®Æ®w¤¤¥þ³¡ªº¸ê®Æ®wªíªº¦W¦r¡C

¤W­z³o¨Ç¤èªk¦b©I¥s®É³£»Ý­n¤@­Ó¦r¤¸¦ê²M³æ§@¬°°Ñ¼Æ¡A ¦Ó¥B³£ªð¦^¤@­Ó¦r¤¸¦ê²M³æªº­È¡C

TSession³¡¥óÁÙ¦³¤@­Ó¥sDropConnectionsªº¤èªk¥Î©ó±±¨îÀ³¥Îµ{¦¡»P¸ê®Æ®wªº³s±µ¡A·í©I¥sDropConnections¤èªk®É¡AÀ³¥Îµ{¦¡»P©Ò¦³ªº¸ê®Æ®wªº³s±µ±N·|¤ÁÂ_¡C¡@

15.2.3 TSession³¡¥óÀ³¥ÎÁ|¨Ò¡@

¨Ò15.1¡G§Ú­Ì«Ø¥ß¤@­ÓÀ³¥Îµ{¦¡¡A³q¹L©I¥sTSession¦³Ãöªº¤èªkÀò¨ú¥Ø«eÀ³¥Îµ{¦¡¥i¥H¶i¦æ³s±µªº¸ê®Æ®wªº¦W¦r¥H¤ÎÀò¨ú¨ä¤¤¥ô·N¤@­Ó¸ê®Æ®w¤¤ªº¥þ³¡¸ê®Æ®wªíªº¦W¦r¡C¡@

³q¹LTSession³¡¥óÀò¨ú¸ê®Æ®wªº¦³Ãö¸ê°T¡@

µ¡Å餤¥D­n¨Ï¥Î¤F¨â­Ó¦C¥Ü¤è¶ô¡A¨ä¤¤¦C¥Ü¤è¶ôDatabaselistBox¥Î©óÅã¥Ü¸ê®Æ®wªº¦W¦r¡A¦C¥Ü¤è¶ôTablelistBox¥Î©óÅã¥Ü¸ê®Æ®w¤¤ªºªí¦W¡Cµ{¦¡°õ¦æ§¹«á¸ê®Æ®wªº¦W¦rÅã¥Ü¦bDatabaselistBox¦C¥Ü¤è¶ô¤¤¡A·í¥Î¤á«ö¤@¤UDatabaselistBox¦C¥Ü¤è¶ô¤¤ªº¸ê®Æ®w¦W®É¡A¸Ó¸ê®Æ®w¥þ³¡ªº¸ê®Æ®wªíªº¦W¦r±N·|Åã¥Ü¦bTablelistBox¦C¥Ü¤è¶ô¤¤¡C¦³Ãöªºµ{¦¡¥N½X¦p¤U¡G¡@

µ{¦¡²M³æ15.1

unit unit31;¡@

interface¡@

uses

SysUtils, Windows, Messages, Classes, Graphics, Controls,

Forms, Dialogs, StdCtrls, DB, DBTables, Buttons, ComCtrls, Tabnotbk;¡@

type¡@

TQueryForm = class(TForm)

BitBtn1: TBitBtn;

DataSource1: TDataSource;

Table1: TTable;

GroupBox1: TGroupBox;

CheckBox1: TCheckBox;

CheckBox2: TCheckBox;

PageControl1: TPageControl;

TabSheet1: TTabSheet;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

ListBox1: TListBox;

ListBox2: TListBox;

ListBox3: TListBox;

TabSheet2: TTabSheet;

Memo1: TMemo;

procedure FormCreate(Sender: TObject);

procedure ListBox1Click(Sender: TObject);

procedure ListBox2Click(Sender: TObject);

end;

¡@

var

QueryForm: TQueryForm;

¡@

implementation

¡@

{$R *.DFM}

¡@

uses RSLTFORM;

¡@

procedure TQueryForm.FormCreate(Sender: TObject);

begin

Screen.Cursor := crHourglass;

¡@

{ Populate the alias list }

¡@

with ListBox1 do

begin

Items.Clear;

Session.GetAliasNames(Items);

end;

¡@

{ Make sure there are aliases defined }

¡@

Screen.Cursor := crDefault;

if ListBox1.Items.Count < 1 then

MessageDlg( 'There are no database aliases currently defined. You ' +

'need at least one alias to use this demonstration.',

mtError, [mbOK], 0 );

end;

¡@

procedure TQueryForm.ListBox1Click(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 ListBox1 do

strValue := Items.Strings[ItemIndex];

¡@

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

appropriate list box, making sure the user's choices are reflected

in the list. }¡@

ListBox2.Items.Clear;

Session.GetTableNames(strValue, { alias to enumerate }

'', { pattern to match }¡@

15.3.4 ¼Æ¾Ú¶°¤¤ªº¼Æ¾ÚºûÅ@¡@

¼Æ¾Ú¶°¤¤ªº¼Æ¾ÚºûÅ@¥D­n¥]¬A¼Æ¾Ú°O¿ýªº­×§ï¡A´¡¤J©M¸Ñ°£¡CDelphi¬°¼Æ¾Ú¶°³¡¥ó´£¨Ñ¤F¬ÛÀ³ªº¤èªk¥Î©ó¨ä¤¤ªº¼Æ¾ÚºûÅ@¡C³o¨Ç¤èªk¦pªí15.©Ò¥Ü¡C¡@

ªí15.3 Delphi¥Î©ó¼Æ¾ÚºûÅ@ªº¤èªk

¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w

¤è ªk ¦W ¥\ ¯à

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Edit ±N¼Æ¾Ú¶°¸m¬°½s¿èª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Append §ë±H©Ò¦³³Q­×§ïªº°O¿ý¡A±N°O¿ý«ü¼Ð²¾¨ìªí¤¤ªº³Ì«á

¤@±ø°O¿ý¡A¥B±N¼Æ¾Ú¶°¸m¬°´¡¤Jª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Insert §ë±H©Ò¦³³Q­×§ïªº°O¿ý±N¼Æ¾Ú¶°¸m¬°´¡¤Jª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Post ±N´¡¤Jªº·s°O¿ý©M­×§ïªº°O¿ý¼g¦^ºÏºÐ¤Wªº¸ê®Æ®wªí¡A

§Y§ë±H¡A·í§ë±H¦¨¥\®É¼Æ¾Ú¶°¦^¨ìÂsÄýª¬ºA¡A­Y§ë±H

¤£¦¨¥\¼Æ¾Ú¶°¤´µM«O«ù­ì¦³ª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Cancel ¨ú®ø¥Ø«eªº¾Þ§@¥B±N¼Æ¾Ú¶°¸m¬°ÂsÄýª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

Delete ¸Ñ°£¥Ø«e°O¿ý«ü¼Ð©Ò¦bªº°O¿ý¥B±N¼Æ¾Ú¶°¸m¬°ÂsÄýª¬ºA

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

AppendRecord ¦bªíªº³Ì«á´¡¤J¤@±ø·s°O¿ý¡A°O¿ýªº¦U­ÓÄæ¦ì­È§@¬°

AppendRecordªº°Ñ¼Æ¶Ç»¼µ¹·s°O¿ý

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

InsertRecord ¦b¥Ø«e«ü¼Ð©Ò¦b°O¿ýªº«á­±´¡¤J¤@±ø·s°O¿ý¡A °O¿ýªº

¦U­ÓÄæ¦ì­È§@¬°InsertRecordªº°Ñ¼Æ¶Ç»¼µ¹·s°O¿ý¡C

¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X¡X

SetRecords ­×§ï¥Ø«e°O¿ý¡AÄæ¦ì¦W©M¬ÛÀ³ªºÄæ¦ì­È§@¬°SetRecords

ªº°Ñ¼Æ

¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¡@

Edt¤èªk¡G¦pªGÀ³¥Îµ{¦¡·Q¹ï¼Æ¾Ú¶°¤¤ªº¼Æ¾Ú°O¿ý¶i¦æ­×§ï¡A§Ú­Ì¥²¶·­n±N¼Æ¾Ú¶°³]©w¦¨½s¿èª¬ºA¡C©I¥s¼Æ¾Ú¶°³¡¥óªºEdit¤èªk«K¥i¥H±N¼Æ¾Ú¶°¸m¦¨½s¿èª¬ºA¡A·í¼Æ¾Ú¶°¤w¸g³B¦b½s¿èª¬ºA®É¡A©I¥sEdit¤èªk¤£·|²£¥Í§@¥Î¡C·í¼Æ¾Ú¶°³B©ó½s¿èª¬ºA®É¡A²¾°Ê°O¿ý«ü¼Ð©Î©I¥spost¤èªk³£¥i¥H±N¥Ø«e°O¿ýªº­×§ï¼g¦^¨ìºÏºÐ¸ê®Æ®wªí¤¤¡C¦bµ{¦¡¤¤¡A Edit¤èªk©Mpost¤èªk±`±`°t¦X¦b¤@°_¨Ï¥Î¡A¥Î©ó­×§ïªí¤¤ªº°O¿ý¡C¦p¡G¡@

Table1.Edit;

Tabel1.FieldByName('CustNo').Asstring := '1234';

Table1.st;¡@

¦b¤W­z³o¤@¬qµ{¦¡¥N½X¤¤¡A²Ä¤@¦æµ{¦¡¬O±NTable1¸m¦¨½s¿èª¬ºA¡A²Ä¤G¦æµ{¦¡¬O¹ï¥Ø«e°O¿ý«ü¼Ð©Ò¦bªº°O¿ýªºCustNoÄæ¦ìªº­È­×§ï¦¨'1234'¡A²Ä¤G¦æµ{¦¡¬O©I¥spost¤èªk±N¹ï¥Ø«e°O¿ýªº­×§ï¼g¦^¸ê®Æ®wªí¡C

Append¤èªk©MInsert ¤èªk¡G³o¨â­Ó¤èªk³£¬O±N¼Æ¾Ú¶°³¡¥ó¸m¦¨´¡¤Jª¬ºA¡A¥H¦bªí¤¤´¡¤J·s°O¿ý¡AInsert¤èªk¬O¦b¥Ø«e«ü¼Ð¦ì¸mªº°O¿ý«á­±´¡¤J¤@¥´·s°O¿ý¡AAppend¤èªk¬O¦bªíªº§À³¡´¡¤J¤@¥´·s°O¿ý¡A¤£¹L³o­nª`·N¡AµL½×¥Î¤á¬O©I¥sInsert¤èªkÁÙ¬OAppend¤èªk´¡¤J·s°O¿ý¡A¼W¥[°O¿ý¨ì¤@­Ó¨ã¦³¯Á¤Þªºªí¤¤®É¡A³£¬O«ö·Ó¯Á¤Þ¶¶§Ç¼g¤J¨ä¦ì¸m¡A¤]´N¬O»¡¹ï©ó¯Á¤Þªí®æInsert¤èªk©MAppend¤èªkªº§@¥Î¬O¤@¼Ëªº¡AAppend¶È¾A¥Î©ó¨S¦³¯Á¤Þªºªí¡CInsert¤èªk©MAppend¤èªk¹ê»Ú¤W¬O±N¼Æ¾Ú¶°¸m¦¨´¡¤Jª¬ºA¡A¨Ã¥B´¡¤J¤@±øªÅ¥Õ°O¿ý¡A­n¯u¥¿´¡¤J¤@±ø·s°O¿ý¡A§Ú­Ì¥²¶·¦b©I¥sInsert©ÎAppend¤èªk¤§«á¡AÁÙ­nµ¹·s°O¿ýªº¦U­ÓÄæ¦ì½á­È¡A³Ì«á©I¥spost¤èªk¡A±N´¡¤Jªº°O¿ý¼g¦^¸ê®Æ®wªí¡C©I¥s³o¨âºØ¤èªk´¡¤J·s°O¿ýªº¤@¯ë¨BÆJ¦p¤U¡G¡@

With tabe1 DO

Begin

Insert; {©I¥sInsert¤èªk¡A´¡¤J¤@±øªÅ°O¿ý}

¡Õ¬°°O¿ýªº¦UÄæ¦ì½á­È¡Ö

Post;

End;¡@

Post¤èªk¡G¼Æ¾Ú¶°¤¤ªº°O¿ý³Q­×§ï©Î´¡¤J·s°O¿ý®É©I¥spost¤èªk±N¼Æ¾Ú¶°ªº­×§ï¼g¦^¨ì¸ê®Æ®wªí¡C®Ú¾Ú¼Æ¾Ú¶°©Ò³Bªºª¬ºA¤£¦P¡Apost¤èªk©Ò²£¥Íªº§@¥Î©M®ÄªG¬O¤£¤@¼Ëªº¡G

¡´ ·í¼Æ¾Ú¶°³B©ó½s¿èª¬ºA®É¡A©I¥spost¤èªk¡A±N¥Ø«e°O¿ýªº­×§ï¼g¦^¸ê®Æ®wªí

¡´ ·í¼Æ¾Ú¶°³B©ó´¡¤Jª¬ºA®É¡A©I¥spost¤èªk¡A±N´¡¤Jªº·s°O¿ý¼g¦^¸ê®Æ®wªí

¡´ ·í¼Æ¾Ú¶°³B©óSetKeyª¬ºA®É¡A©I¥spost¤èªk¡A±N¼Æ¾Ú¶°¸m¦¨ÂsÄýª¬ºA(Browseª¬ºA)

¡@

post¤èªkªº©I¥s¬J¥i¥HÅ㦡¦a©I¥s¡A¤]¥i¥HÁô§t¦a©I¥s¡A·í¼Æ¾Ú¶°³B©ó½s¿èª¬ºA©Î´¡¤Jª¬ºA®É¡A·í²¾°Ê°O¿ý«ü¼Ð®É¡ADelphi·|Áô§t¦a©I¥spost¤èªk¡A±N±N¥Ø«e°O¿ýªº­×§ï¼g¦^¸ê®Æ®wªí¡A¦bµ{¦¡©I¥sInsert¤èªk©ÎAppend¤èªk®É¡A¤]·|Áô§t¦a©I¥sPost¤èªk¡A±N¥ý«eªº¼Æ¾Ú¶°ªº­×§ï¼g¦^¸ê®Æ®wªí¡C

Delete¤èªk¡GDelete¤èªk¥Î©ó¸Ñ°£ªí¤¤ªº°O¿ý¡A©I¥sDelete¤èªk®É¡A±N·|¸Ñ°£ªí¤¤¥Ø«eªº°O¿ý¡A¨Ã¥B¦Û°Ê¦a±N°O¿ý«ü¼Ð²¾¨ì³Q§R°O¿ýªº¤U¤@±ø°O¿ý¡A¦P®É±N¼Æ¾Ú¶°¸m¦¨Browseª¬ºA¡C

Cancel¤èªk:Cancel¤èªk¥Î©ó¨ú®ø¥Ø«eªº¾Þ§@¡A·íµ{¦¡ÁÙ¨S¦³©I¥sPost¤èªk¡A±N¹ï°O¿ýªº­×§ï¼g¦^¸ê®Æ®wªí®É¡A©I¥sCancel¤èªk¡A¥i¥H±N°O¿ý«ì´_¨ì¨S¦³­×§ï¤§«eªºª¬ºA¡C¨Ã¥B¦b©I¥sCancel¤èªk®É¡A¥¦Á`¬O±N¼Æ¾Ú¶°¸m¦¨Browseª¬ºA¡C

AppendRecord¤èªk©MInsertRecord¤èªk¡G³o¨â­Ó¤èªk¤À§O»PAppend¤èªk©MInsert¤èªk¬Û¦ü¡C¥¦­Ì³£¬O¥Î©ó¦bªí¤¤´¡¤J¤@±ø·s°O¿ý¡A¦ýAppendRecord¤èªk©MInsertRecord¤èªk¤ñAppend©MInsert¤èªk§ó²³æ§ó¤è«K¤@¨Ç¡A¥¦­Ìª½±µ¦bªí¤¤´¡¤J¤@±ø·s°O¿ý¡A·s°O¿ýªº¦U­ÓÄæ¦ì­È§@¬°AppendRecord©ÎInsertRecord¤èªkªº°Ñ¼Æ¶Ç»¼µ¹·s°O¿ý¨Ã¥B¤£»ÝÅ㦡¦a©I¥spost¤èªk¡A±N´¡¤Jªº·s°O¿ý¼g¦^¸ê®Æ®wªí¡C¦bµ¹´¡¤Jªº·s°O¿ý½áÄæ¦ì­È®É¡A±N¥Ñ¦h­ÓÄæ¦ì­È¸s¸s²Õ¦¨ªº¼Æ¸s¸s²Õ§@¬°AppendRecord©ÎInsertRecordªº°Ñ¼Æ¡A¦bÄæ¦ì­È¼Æ¸s¸s²Õ¤¤¥i¥H¬°¨C¤@­ÓÄæ¦ì´£¨Ñ¤@­Ó­È¡A©Î±q¥ªÃä¤@¦C¶}©l¨Ì¦¸¬°¥ô·N¦h­ÓÄæ¦ì½á­È¡C¤]´N¬O»¡¡A¥Î¤á¥i¥H±q¸ê®Æ®wªíªº³Ì¥ª¤@¦C°_¡A§â³\¦h¦Cªº­È¦P®É¶Ç»¼µ¹InsertRecord¡Aª½¨ì©Ò¦³ªºÄæ¦ì³Q½á­È¡A¥Î¤á¤]¥i¥H¬Ù²¤Äæ¦ì§Ç¦C«á­±ªºªº¤@¨ÇÄæ¦ì­È¡AInsertRecord·|¥ÎªÅ­È¨Ó¶ñ¥R³o¨ÇÄæ¦ì¡G¥Î¤á¤]¥i¥H¹ï¨º¨Ç©ú½T§Æ±æ¥ÎªÅ¶ñ¥RªºÄæ¦ì¶Ç»¼«O¯d¦rNIl¡C

¨Ò¦p¡G¦pªGªíCountry¦³Name¡ACaptial¡AContinent¡AArea©MPopulationÄæ¦ì¡A ¨Ã¥B¼Æ¾Ú¶°³¡¥óTable1»P¥¦¬Û³s¡A¤U­±ªº¥N½X«K¥i¥H¦bCountryªí¤¤¥Ø«e°O¿ýªº«á­±´¡¤J¤@±ø·s°O¿ý¡C

¡@

Table1.InsertRecord (["¤¤°ê","¥_¨Ê","¤­¬w"]);

¡@

¦b¤W­z¥N½X¤¤¨S¦³¬°Area©MpopulationÄæ¦ì½á­È¡AInsertRecord·|¥ÎªÅ­È¨Ó¶ñ³o¨â­ÓÄæ¦ì¡C

SetRecords¤èªk¡G©I¥s¸Ó¤èªk¥i¥H­×§ïªí¤¤¥Ø«e°O¿ýªº¦h­ÓÄæ¦ìªº­È¡A©I¥s¸Ó¤èªk¤§«e¥²¶·±N¼Æ¾Ú¶°³¡¥ó¸m¦¨½s¿èª¬ºA¡A©I¥s¸Ó¤èªk¤§«á¡AÁÙ­n©I¥spost¤èªk¡A¤~¯à¯u¥¿±N¥Ø«e°O¿ýªº­×§ï¼g¦^¸ê®Æ®wªí¡C©I¥sSetRecord¤èªk®É¡A³Q­×§ïªºÄæ¦ì­È¥²¶·­n»Pªí¤¤¹ê»Ú¦s¦bªºÄæ¦ì¦W¹ïÀ³¡A¨Ã¥B¼Æ¾Ú«¬¦¡­n¬Û¤Ç°t¡C¨Ò¦p¡A¤U­±ªº¥N½X¬O­×§ï¤W­±­è­è´¡¤Jªº¨º±ø°O¿ý¡C

¡@

Table1.Edit;

Tabel1.SetRecord(¡A ¡A ¡A9600000,1200000000);

Tabel1.post;

¡@

³o¤@¬q¥N½X¬O­×§ï¤W­±­è­è´¡¤Jªº¨º±ø°O¿ýªºArea ©MPopulation Äæ¦ìªº­È¡A¦Ó¹ïName,Continent©MCaptialÄæ¦ì¨S¦³­×§ï¡C

¦b¼Æ¾Ú¶°³¡¥ó¤¤¡AÁÙ¦³¤@­Ó­«­n¤èªkAbort¤èªk¡A¸Ó¤èªk¬O¥Î©ó¨ú®ø¨ä¥L¤èªkªº©I¥sªº¡A¦p¦b´¡¤J°O¿ý¡B­×§ï°O¿ý©M¸Ñ°£°O¿ý¤§«e¡A©¹©¹»Ý­n¥Î¤á½T»{¬O§_¯uªº­n°õ¦æ³oºØ¾Þ§@¡A¦¹®É©I¥sAbort¤èªk«K¥i¨ú®ø¦UºØ¤èªkªº©I¥s¡A¤U­±ªº¥N½X¬O¦b¥Î¤á¸Ñ°£¤@±ø°O¤§«e¡AÅý¥Î¤á½T»{¬O§_¯uªº­n°õ¦æ¸Ñ°£¾Þ§@¡C¡@

Tabel1.BeforeDelete(DataSet:TDataSet);

If MessageDlg('¯uªº­n¸Ñ°£°O¿ý¶Ü?',

mtConfirmation,mbyesNoCanel,0 <> mryes then

Abort; {¨ú®ø¸Ñ°£¾Þ§@}¡@

Ãö©ó®Ññ(BookMark)¾Þ§@¡F

®Ññ¾Þ§@¥D­n¥Î©ó¦bªí¤¤§Ö³t¦a©w¦ì°O¿ý«ü¼Ð¡A¦bÀ³¥Îµ{¦¡¤¤±`±`­n¦sÀÉ°O¿ý«ü¼Ð©Ò¦bªº¦ì¸m¡A¦b¶i¦æ¨ä¥L³B²z¤§«á¡A§Æ±æ¯à§Ö³t¦aªð¦^¨ì¥ý«e«ü¼Ð©Ò¦bªº¦ì¸m¡A¦¹®É¡A¨Ï¥Î®Ññ±NÅã±o¯S§O¦³¥Î¡C¦³Ãö®Ññ¾Þ§@¡ADelphi´£¨Ñ¤F¤T­Ó¤èªk¡A¥¦­Ì¬O¡G

¡´ GetBookMark

¡´ GotoBookMark

¡´ FreeBokMark

¡@

³o¤T­Ó¤èªk¤@¯ë³£¬O¦b¤@°_¨Ï¥Î¡AGetBookMark¤èªkªð¦^¤@­ÓTBookMark«¬¦¡ªºÅܼơA¸ÓÅܼƥ]§tµÛ«ü¦V¥Ø«e°O¿ýªº«ü¼Ð¡AGotoMark¤èªk¥Î©ó§Ö³t¦a±N°O¿ý«ü¼Ð©w¦ì¨ì¨ã¦³®Ññªº°O¿ý³B¡CFreeBookmark¤èªk¬O»PGetBookMark¤èªk¬Û¤Ïªº¾Þ§@¡A¥¦ÄÀ©ñ®Ññ¼Ð»x¡C¤U­±ªºµ{¦¡¥N½XÄÄ­z¤F®Ññ¾Þ§@ªº¤@¯ë¤èªk¡G

¡@

BookMark : TBookMark;

<Do something>

BookMark := Table1.GetBookMark; {¹ï¥Ø«e°O¿ý§@®Ññ¼Ð»x}

Table1.DisalbeControls; {¤ÁÂ_Table1»P¼Æ¾Ú¹îı³¡¥óªºÁpô}

Table.First

While Not EOF Do {¹ïªí¤¤¥þ³¡°O¿ý¶i¦æ¨ä¥L³B²z}

begin

<Do something>

Tabel1.Next;

end;

Tabel1.GotoBookMark(BookMark)

Table1.enableControls; {­«·s©w¦ì°O¿ý«ü¼Ð¦^¨ì­ì¨Óªº¦ì¸m}

Tabel1.FreeBookMark(BookMark); {¸Ñ°£®ÑñBookMark¼Ð»x}¡@

15.3.5 ¼Æ¾Ú¶°³¡¥ó»P¼Æ¾ÚÂsÄý³¡¥óªº³s±µ¡@

      ¼Æ¾Ú¶°³¡¥óTTabel©MTQuery¨ã¦³¤T­Ó¤èªk¡ADisableControls ¤èªk¡BEnableControls¤èªk¡BRefresh¤èªk¥Î©ó±±¨î¼Æ¾Ú¶°³¡¥ó©M»P¨ä¬Û³sªº¼Æ¾ÚÂsÄý³¡¥ó¤§¶¡ªº³s±µ¡A¥H¤Î±±¨î¼Æ¾ÚÂsÄý³¡¥óªºÅã¥Ü¡C¦b¥Î¤á­×§ï©M§ó·s¥H¤Î¹M¾ä¸ê®Æ®wªí¤¤ªº°O¿ý®É¡A©I¥sDisableControls¤èªk¨ã¦³­«­n·N¸q¡A©I¥sDisbaleControls¤èªk¥H¤ÁÂ_TTable©ÎTQuery³¡¥ó»P¼Æ¾ÚÂsÄý³¡¥óªº³s±µ¡A¨Ï¼Æ¾ÚÂsÄý³¡¥ó¼È®É¥¢®Ä¡A§_«h¡A¦b¹ïTTable©ÎTQuery³¡¥óªº¨C¦¸­×§ï¤§«á¡Aµ¡Å餤©Ò¦³»P¥¦­Ì¬Û³sªº¼Æ¾ÚÂsÄý³¡¥ó³£­n§ó·s¨äÅã¥Ü¤º®e¡A³o¿ËÅãµM·|´îºC³B²z³t«×¡C·í¹M¾äªí¤¤ªº°O¿ý®É°O¿ý«ü¼Ð¨C²¾°Ê¤@¤U¡Aµ¡Å餤ªº¼Æ¾ÚÂsÄý³¡¥ó¤]ÀH¤§§ó·s¤@¤U¨ä¤¤ªºÅã¥Ü¤º®e¡A¦b¿Ã¹õ¤W²£¥Í°{Ã{¡C

EnableControls¤èªkªº§@¥Î»PDisbaleControls¤èªkªº§@¥Î¬O¬Û¤Ïªº¡A©I¥sEnableControls¤èªk¡A¨ÏTTable©ÎTQuery³¡¥ó«ì´_»P¼Æ¾ÚÂsÄý³¡¥óªº³s±µ¡A¨Ï¼È®É¥¢®Äªº¼Æ¾ÚÂsÄý³¡¥ó«ì´_¨ì¥¿±`Åã¥Üªí¤¤°O¿ý¸ê°Tªºª¬ºA¡C

Refresh¤èªk¥Î©ó¨ê·s¼Æ¾ÚÂsÄý³¡¥ó¤¤ªºÅã¥Ü¡C¦b©I¥sRefresh¤èªk®É¡A¥²¶·­n½T«OTTable©ÎTQuery³¡¥ó¬O¥´¶}ªº¡C·í¼Æ¾Ú¶°¤¤ªº°O¿ý³Q­×§ï¤§«á¡A©I¥sRefresh¤èªk¡A¼Æ¾ÚÂsÄý³¡¥ó¤¤Åã¥Üªº¸ê°T¤]ÀH¤§§ïÅÜ¡C

¡@


«á¤@­¶
«e¤@­¶
¦^¥Ø¿ý
¦^­º­¶