Questo è un esempio di codice tratto dalla Guida in linea di Delphi:
Si tratta di definire il database di lavoro, il nome della tabella, aggiungere la struttura dei campi e le relative caratteristiche.codice:with Table1 do begin Active := False; DatabaseName := 'DBDEMOS'; TableType := ttParadox; TableName := 'CustInfo'; { Don't overwrite an existing table } if not Table1.Exists then begin { The Table component must not be active } { First, describe the type of table and give } { it a name } { Next, describe the fields in the table } with FieldDefs do begin Clear; with AddFieldDef do begin Name := 'Field1'; DataType := ftInteger; Required := True; end; with AddFieldDef do begin Name := 'Field2'; DataType := ftString; Size := 30; end; end; { Next, describe any indexes } with IndexDefs do begin Clear; { The 1st index has no name because it is { a Paradox primary key } with AddIndexDef do begin Name := ''; Fields := 'Field1'; Options := [ixPrimary]; end; with AddIndexDef do begin Name := 'Fld2Indx'; Fields := 'Field2'; Options := [ixCaseInsensitive]; end; end; { Call the CreateTable method to create the table } CreateTable; end; end;
L'esempio riportato sopra è relativo al BDE, così come quello riportato qui sotto, sempre preso dalla Guida in linea, il quale mostra come accodare un record alla tabella, compilare i campi con un valore e salvare le modifiche.
Purtroppo non ho il tempo materiale di elaborare esempi più estesi.codice:procedure TForm1.Button1Click(Sender: TObject); begin SampleTable.Append; SampleTable.FieldValues['ALPHANUMERIC'] := Edit1.text; SampleTable.FieldValues['INTEGER'] := StrToInt(Edit2.text); SampleTable.Post; end;
Ciao!![]()


Rispondi quotando