Разработка приложений баз данных в среде Delphi. Часть 1: Методическое пособие

  • View
    236

  • Download
    11

Embed Size (px)

Transcript

  • . ., . .

    Delphi. I.

    4 / 4 /

    , 2002

  • 2

    4 - . - Delphi Windows 9X/NT/2000. Delphi - - Windows Object Pascal, ( ). - Delphi (- ) , , -, . ( Delphi Clarion, ++ Builder, Power Builder , , Visual Basic.) Delphi - , -. - , , Microsoft Access Paradox. . : , , . - Delphi . - , , - . [1-3]. SQL [4]. [1,2,5] - InterBase. - Delphi [6-9], - [10-12]. - Delphi . , 1 4 - , SQL, Delphi. - Delphi 4.0-6.0. , , Web- - www.main.vsu.ru/~pmmtkiar.

    http://www.main.vsu.ru/~pmmtkiar

  • 3

    1.1. Delphi : (DataBase

    Desktop, ReportSmith, DataBase Explorer, WISQL). Delphi . . - , , , .. Delphi - . , -, - . , - BDE (Borland DataBase Engine, - ). BDE Delphi. BDE Windows. BDE - (DLL). BDE , , SQL . , BDE, IDAPI. BDE , . BDE. . BDE - Paradox (*.db), dBase (*.dbf), ASCII, FoxPro, Access. , BDE - SQL- InterBase, Oracle, Informix . BDE . Delphi 5 Borland SQL Server InterBase 5, -/ , -. BDE . (Alias, ) - - , . , Delphi DBDEMOS - PROGRAM FILES\COMMON FILES\BORLAND SHARED\DATA\, - . - , . : - , - , , DB Explorer -

  • 4

    BDE Administrator. BDE idapi.cfg. Windows NT/2000 idapi.cfg . Paradox Inter-Base. Paradox (*.db), InterBase *.gdb. : Paradox FoxPro, , Data Base Desktop (DBD) DB Explorer, Delphi, InterBase Windows ISQL. , DBD 1) 2) InterBase. DBD , - . DB Explorer ( SQL Explorer) SQL- . InterBase, .. InterBase, . ( DB Explorer .) InterBase Windows ISQL, ( , , , , .).

    1.2. Delphi , . - 4 : Data Access ( ), Data Con-trols ( Standard Additional, ), Midas ( ), InterBase ( - , InterBase - , BDE). . 1.2.1. DataAccess , - , .. . , . .

  • 5

    DataSource . -

    . Table . -

    (). Query .

    SQL. StoredProc . , -

    , , InterBase, Oracle, MS SQL Server . .

    DataBase .

    Session . BatchMove .

    , , - Paradox InterBase.

    UpdateSQL , - SQL- .

    NestedTa-ble

    . ,

    1.2.2. DataControls DBGrid .

    DbNavigator .

    , -.

    DBText ( ) - .

    DBEdit .

    DBMemo . - (Memo).

    DBImage .

    DBListBox . - , , .

    DBComboBox . Com-boBox Standard, .

    DBCheckBox . . DBRadioGoup .

    .

  • 6

    DBLookU-pListBox

    . DBListBox , , - , DBListBox - .

    DBLokUp-ComboBox

    . DBComboBox .

    DBRichEdit RTF-. , -.

    DBCtrlGrid DBChart ,

    1.2.3. , , , - , . - , - . TTable ( ), TQuery ( SQL- ) TStored-Proc ( ). - , TDataSource, TTable TQuery - ( ) - . -, -, ( , - ., ). TTable, TDataSource TDBGrid. . TTable - - ( ). , - , TTable, : DataBaseName, String - ,

    , . TableName: TFileName - .

    TTable BDE. Name - . -

    Table1. Active, Boolean - Active True -

    . - False. : IndexName: String - , IndexFieldNames: String - .

    . 1. :

    , .

  • 7

    2. , - .

    3. IndexName , IndexFieldNames - , , .

    4. , IndexFieldNames - , .

    5. - , . MasterSource: TDataSource - TDataSource, -

    . MasterFields: String - ,

    . Filter: String - . Filtered: Boolean - True . -

    False. TTable (DataBaseName TableName), . - TDataSource c TTable. DataSet: TDataSet ( Name) - TTable. TDBGrid ( ) - . DBGrid , - DataSource TDataSource, - . TDataSource TDBGrid - , , . - . TDBGrid - , ( Table), - - .

    1. .

    1. . TTable TDataSource. Data Access - . - : - , .

    2. Table1 Da-taBaseName. DBDemos.

    3. TableName DBDemos. , TableName . , , country.db (- ).

    4. DataSource1. Table1, Table1 DataSet.

  • 8

    5. TDBGrid ( Data Control - ). DataSource1, DataSource1 DataSource. .1.

    6. Active Table1 True. (DBGrid).

    7. . 8. Active False, OnCre-

    ate Table1.Open. . , 8.

    . 1

    , . TDBEdit ( Data Control). - TDBEdit, . - : DataSource ( - - ) DataField ( - ). ( Graphics, Blob) (- Memo) TDBImage TDBMemo, -. TDBNavigator. . , - , , - . DataSource DataField.

  • 9

    2 () biolife.db, . TDBGrid TDBEdit, TDBImage, TDBMemo TDBNavigator. TLabel . - .2.

    .2

    1.3. . - - , . - . , , - - , . , CustNo. CustNo . TTable - MasterSource ( DataSource ), MasterField ( ), Index-FieldNames ( , ). , - . - , .

  • 10

    3 , - - customer.db orders.db.

    1. TTable, TDataSource TDBGrid ( ) DBNavigator .

    2. customer.db orders.db, . , MasterSource, MasterField, IndexFieldNames . - . 3.

    3. . 4. Form Wizard

    ( DataBase).

    . 3

    4 (). . , . Cus-tomer.db , Orders.db, , , Items.db. Items - . , - . Orders Items OrderNo.

  • 11

    1.4. - . - -. 2.0, Delphi - , - DataSet DataSource - (Data Module). , . - , . M - TQuery, TTable. - [2], , - , . , - , ( ). . (Data Module) (Unit) - . - , Unit.

    5 - - 1.

    1. . File | New Data Module. - . TTable TDataSource - . , . - ( Name) - CountryTables.

    2. . , - Unit2, , TDataModule, TForm. File | Save As - CountryModule. CountryModule.pas Coun-tryModule.dfm.

    3. File | Close All. . , - Country.db. , .

    1. File | New Application. 2. Project | Add to Project...

    . - , File | Use Unit CountryModule. Use Unit1 .

  • 12

    3. TDBGrid TDataSource, CountryTables.DataSource1. . - 1-4.

    2. Delphi . , TTable, - . (Record- ). TQuery, , - , SQL. - SQL- , . - TDataSet ( ) - TDataSet , . , , , , - , TTable. , - , , . 2.1. ? - , ( , . .2.2). - TField (- ). , Address Cust ( . .2.3) with Table1 do begin Edit; // FieldByName(Address).value:=;// TField Post; // end; TField ( ) , , . -, Value Variant , DisplayLabel , DisplayFormat . . (Variant , - . Variant , - . - . . [10].) TField -, - (TStringField, TBooleanField, TDateField, TFloatField, TIntegerField .). .

  • 13

    2.1.1. - TField . . TField

    , . - . , - .

    . TField ( ) . - , .

    ,