, Borland Delphi 7 Developer's Guide 

[ Pobierz całość w formacie PDF ]
.Define your new field with type DataSetField.In the Fields Editor, define the structure of the detail table.You must also addpersistent fields for any other fields used in your master dataset.Under s t andi ng dat as et s 24-37 Us i n g t a b l e t y p e d a t a s e t sThe dataset component for the detail table is a dataset descendant of a type allowedby the master table.TTable components only allow TNestedDataSet components asnested datasets.TSQLTable components allow other TSQLTable components.TClientDataset components allow other client datasets.Choose a dataset of theappropriate type from the Component palette and add it to your form or datamodule.Set this detail dataset s DataSetField property to the persistent DataSet fieldin the master dataset.Finally, place a data source component on the form or datamodule and set its DataSet property to the detail dataset.Data-aware controls can usethis data source to access the data in the detail set.Controlling Read/write access to tablesBy default when a table type dataset is opened, it requests read and write access forthe underlying database table.Depending on the characteristics of the underlyingdatabase table, the requested write privilege may not be granted (for example, whenyou request write access to an SQL table on a remote server and the server restrictsthe table s access to read only).Note This is not true for TClientDataSet, which determines whether users can edit datafrom information that the dataset provider supplies with data packets.It is also nottrue for TSQLTable, which is a unidirectional dataset, and hence always read-only.When the table opens, you can check the CanModify property to ascertain whether theunderlying database (or the dataset provider) allows users to edit the data in thetable.If CanModify is False, the application cannot write to the database.If CanModifyis True, your application can write to the database provided the table s ReadOnlyproperty is False.ReadOnly determines whether a user can both view and edit data.When ReadOnly isFalse (the default), a user can both view and edit data.To restrict a user to viewingdata, set ReadOnly to True before opening the table.Note ReadOnly is implemented on all table type datasets except TSQLTable, which isalways read-only.Creating and deleting tablesSome table type datasets let you create and delete the underlying tables at designtime or at runtime.Typically, database tables are created and deleted by a databaseadministrator.However, it can be handy during application development and testingto create and destroy database tables that your application can use.Creating tablesTTable and TIBTable both let you create the underlying database table without usingSQL.Similarly, TClientDataSet lets you create a dataset when you are not workingwith a dataset provider.Using TTable and TClientDataSet, you can create the table atdesign time or runtime.TIBTable only lets you create tables at runtime.24-38 Dev el oper  s Gui de Us i n g t a b l e t y p e d a t a s e t sBefore you can create the table, you must be set properties to specify the structure ofthe table you are creating.In particular, you must specify" The database that will host the new table.For TTable, you specify the databaseusing the DatabaseName property.For TIBTable, you must use a TIBDatabasecomponent, which is assigned to the Database property.(Client datasets do not usea database.)" The type of database (TTable only).Set the TableType property to the desired typeof table.For Paradox, dBASE, or ASCII tables, set TableType to ttParadox, ttDBase,or ttASCII, respectively.For all other table types, set TableType to ttDefault." The name of the table you want to create.Both TTable and TIBTable have aTableName property for the name of the new table.Client datasets do not use atable name, but you should specify the FileName property before you save the newtable.If you create a table that duplicates the name of an existing table, the existingtable and all its data are overwritten by the newly created table.The old table andits data cannot be recovered.To avoid overwriting an existing table, you can checkthe Exists property at runtime.Exists is only available on TTable and TIBTable." The fields for the new table [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • anikol.xlx.pl