第二十一章 ActiveX Data Objects

  • View
    36

  • Download
    3

Embed Size (px)

DESCRIPTION

ActiveX Data Objects. - PowerPoint PPT Presentation

Transcript

  • ActiveX Data Objects17 , Borland Database Engine (BDE) , ActiveX Data Objects(ADO)Borland Delphi C++Builder , ADO ADO , , ADOTable ADOQuery BDE Table Query

    ADO

  • ADO BDE 16 , BCB 4 , BDE ADO dbExpress InterBase, , BDE ADOdbExpress InterBase

    BDE , Table Query QuickRep ADO, , , , ADO , BDE ADO ,

  • 2 1 -1 ADO 17-1 , BDE , ADO, BDE Table ADO ADOTable ,

  • 21-1aADOTable , school.mdb stugrade

  • 2 1 - 2 BDE , Table Query , ADO , ADOTable ADOQuery

  • ADOTableADOTable Table , , , ADOTable FieldByName Fields[]ADOTable1->FieldValues[" "] ;ADOTable1->FieldByName(" ")->;ADOTable1->Fields->Fields[]->;

  • AsVariant AsString AsInteger AsFloat AsCurrency AsDateTime AsBoolean Text1 AsString String 0 Name Edit1 Edit1->Text = ADOTable1->FieldValues["Name"] ;Edit1->Text = ADOTable1->FieldByName("Name")->AsString ;Edit1->Text = ADOTable1->Fields->Fields[0]->AsString ;Name ADOTable1Name->Value ; // ADOTable1Name->AsString ;

  • ADOTable , , , , , , ,

  • 21-2a

  • , , ADOTable1name ADOTable1chi ADOTable1eng , , ADOTable1name Edit1Edit1->Text=ADOTable1name->AsString ;

  • 21-2b

  • , Insert Post , Insert Post , FieldByName (" ") , ,

  • // AsStr ing AsIntegerADOTable1->Insert() ;// 1 StringADOTable1->FieldByName(" 1")->AsString =Edit1->Text ;// 2 IntegerADOTable1->FieldByName(" 2")->AsInteger =StrToInt(Edit2->Text) ;ADOTable1->Post() ;, Test1.mdb grade // AsStr ing AsIntegerADOTable1->Insert() ;ADOTable1->FieldByName("Name")->AsString = "" ;ADOTable1->FieldByName("Chi")->AsInteger = 92 ;ADOTable1->FieldByName("Eng")->AsInteger = 88 ;ADOTable1->Post() ;

  • 21-2c(test1.mdb grade )

  • Delete :ADOTab le 1.De le te ;?,

  • 21-2d()

  • Edit Post , :ADOTable1->Edit() ;ADOTable1->FieldByName(" 1")->AsString =Edit1->Text ;ADOTable1->FieldByName(" 2")->AsInteger =StrToInt(Edit2->Text) ;/ / ADOTable1->Post() ;( DBEdi t)ADOTable1->Post() ;grade ADOTable1->Edit() ;ADOTable1->FieldByName("Name")->AsString = "" ;ADOTable1->FieldByName("Chi")->AsInteger = 22 ;ADOTable1->FieldByName("Eng")->AsInteger = 33 ;ADOTable1->Post() ;

  • 21-2e()1. , " " , DBEdit , " "

  • 2. " ", , , / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/ / void _ _fastcall TForm1::btnEdit1Click(TObject *Sender){ADOTable1->Edit() ;ADOTable1->FieldByName("Name")->AsString = "" ;ADOTable1->FieldByName("Chi")->AsInteger = 92 ;ADOTable1->FieldByName("Eng")->AsInteger = 88 ;ADOTable1->Post() ;}/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  • 3. " " , ,DBText / / void _ _fastcall TForm1::btnEdit2Click(TObject *Sender){ADOTable1->Post() ;}

  • 4. " " , :void _ _fastcall TForm1::btnEdit3Click(TObject *Sender){ADOTable1->First() ;while (! ADOTable1->Eof) {ADOTable1->Edit() ;ADOTable1->FieldByName("Chi")->AsInteger =ADOTable1->FieldByName("Chi")->AsInteger * 1.1 ;ADOTable1->Post() ;ADOTable1->Next() ;}}

  • ADO , Locate Filter, :LocateLocate :virtual bool _ _fastcall Locate(const AnsiString KeyFields,const System::Variant &KeyValues,TLocateOptions Options);:KeyFields: KeyValues: Options: TlocateOptions , , loCaseInsensitive , loPartialKey , " ", " " " ", enum TLocateOption {loCaseInsensitive, loPartialKey};, Locate true, ; false,

  • 21-2f

  • FilterLocate , , "chi>60" "chi
  • 21-2gFilter

  • ADOTable Sort , Sort , ASC, , ASC DESC ADOTable1->Sort = " ";

  • 21-2hSort

  • ADOQueryBDE , Query SQL , ADO ADOQuery SQL , 17-4 19 , ADOQuery Query , ADOQuery test1.mdb grade

  • 21-2iADOQuery (DBGrid test1.mdb grade

  • 21 - 3

  • ADOConnectionADOTable ADOQuery , , ADOTable ADOQuery, ConnectionString, , , ADOConnection ADOConnection ,

  • 21-3a, test1.mdb stuname, stugrd

  • 21 - 4 ADO BDE , ADO test1.mdb grade ADO , 18

  • 21-4a(test1.mdb grade )