Pokrewne
- Strona Główna
- Radiation Protection A Guide for Scientists, Regulators and Physicians Jacob Shapiro
- 802.11 Wireless Networks The Definitive Guide Oreilly Excellent
- The Career Survival Guide Dealing with Office Politics Brian OConnell
- CorelDRAW 11 and Corel RAVE 2 User Guide
- Novell Netware 5 Advanced Admin Instructor guide
- Corel PHOTO PAINT 11 User Guide
- Cisco Press CCDA Study Guide
- Violet Blue The Ultimate Guide to Cunilingus
- Thomas Craig Niedzwiedzie lzy
- Morressy John Kedrigern w krainie koszmarow
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- lala1605.htw.pl
[ Pobierz całość w formacie PDF ]
.To delete a table at runtime, call the dataset s DeleteTable method.Forexample, the following statement removes the table underlying a dataset:CustomersTable.DeleteTable;Caution When you delete a table with DeleteTable, the table and all its data are gone forever.If you are using TTable, you can also delete tables at design time: Right-click the tablecomponent and select Delete Table from the context menu.The Delete Table menupick is only present if the table component represents an existing database table (theDatabaseName and TableName properties specify an existing table).Emptying tablesMany table type datasets supply a single method that lets you delete all rows of datain the table." For TTable and TIBTable, you can delete all the records by calling the EmptyTablemethod at runtime:PhoneTable.EmptyTable;" For TADOTable, you can use the DeleteRecords method.PhoneTable.DeleteRecords;" For TSQLTable, you can use the DeleteRecords method as well.Note, however, thatthe TSQLTable version of DeleteRecords never takes any parameters.PhoneTable.DeleteRecords;" For client datasets, you can use the EmptyDataSet method.PhoneTable.EmptyDataSet;Note For tables on SQL servers, these methods only succeed if you have DELETE privilegefor the table.Caution When you empty a dataset, the data you delete is gone forever.Under s t andi ng dat as et s 24-41Us i n g q u e r y - t y p e d a t a s e t sSynchronizing tablesIf you have two or more datasets that represent the same database table but do notshare a data source component, then each dataset has its own view on the data andits own current record.As users access records through each datasets, thecomponents current records will differ.If the datasets are all instances of TTable, or all instances of TIBTable, or all clientdatasets, you can force the current record for each of these datasets to be the same bycalling the GotoCurrent method.GotoCurrent sets its own dataset s current record tothe current record of a matching dataset.For example, the following code sets thecurrent record of CustomerTableOne to be the same as the current record ofCustomerTableTwo:CustomerTableOne.GotoCurrent(CustomerTableTwo);Tip If your application needs to synchronize datasets in this manner, put the datasets in adata module and add the unit for the data module to the uses clause of each unit thataccesses the tables.To synchronize datasets from separate forms, you must add one form s unit to theuses clause of the other, and you must qualify at least one of the dataset names withits form name.For example:CustomerTableOne.GotoCurrent(Form2.CustomerTableTwo);Using query-type datasetsTo use a query-type dataset,1 Place the appropriate dataset component in a data module or on a form, and set itsName property to a unique value appropriate to your application.2 Identify the database server to query.Each query-type dataset does thisdifferently, but typically you specify a database connection component:" For TQuery, specify a TDatabase component or a BDE alias using theDatabaseName property." For TADOQuery, specify a TADOConnection component using the Connectionproperty." For TSQLQuery, specify a TSQLConnection component using the SQLConnectionproperty." For TIBQuery, specify a TIBConnection component using the Database property.For information about using database connection components, see Chapter 23, Connecting to databases.3 Specify an SQL statement in the SQL property of the dataset, and optionallyspecify any parameters for the statement.For more information, see Specifyingthe query on page 24-43 and Using parameters in queries on page 24-45.24-42 Dev el oper s Gui deUs i n g q u e r y - t y p e d a t a s e t s4 If the query data is to be used with visual data controls, add a data sourcecomponent to the data module, and set its DataSet property to the query-typedataset.The data source component forwards the results of the query (called aresult set) to data-aware components for display.Connect data-aware componentsto the data source using their DataSource and DataField properties.5 Activate the query component.For queries that return a result set, use the Activeproperty or the Open method [ Pobierz całość w formacie PDF ]
zanotowane.pl doc.pisz.pl pdf.pisz.pl agnieszka90.opx.pl
.To delete a table at runtime, call the dataset s DeleteTable method.Forexample, the following statement removes the table underlying a dataset:CustomersTable.DeleteTable;Caution When you delete a table with DeleteTable, the table and all its data are gone forever.If you are using TTable, you can also delete tables at design time: Right-click the tablecomponent and select Delete Table from the context menu.The Delete Table menupick is only present if the table component represents an existing database table (theDatabaseName and TableName properties specify an existing table).Emptying tablesMany table type datasets supply a single method that lets you delete all rows of datain the table." For TTable and TIBTable, you can delete all the records by calling the EmptyTablemethod at runtime:PhoneTable.EmptyTable;" For TADOTable, you can use the DeleteRecords method.PhoneTable.DeleteRecords;" For TSQLTable, you can use the DeleteRecords method as well.Note, however, thatthe TSQLTable version of DeleteRecords never takes any parameters.PhoneTable.DeleteRecords;" For client datasets, you can use the EmptyDataSet method.PhoneTable.EmptyDataSet;Note For tables on SQL servers, these methods only succeed if you have DELETE privilegefor the table.Caution When you empty a dataset, the data you delete is gone forever.Under s t andi ng dat as et s 24-41Us i n g q u e r y - t y p e d a t a s e t sSynchronizing tablesIf you have two or more datasets that represent the same database table but do notshare a data source component, then each dataset has its own view on the data andits own current record.As users access records through each datasets, thecomponents current records will differ.If the datasets are all instances of TTable, or all instances of TIBTable, or all clientdatasets, you can force the current record for each of these datasets to be the same bycalling the GotoCurrent method.GotoCurrent sets its own dataset s current record tothe current record of a matching dataset.For example, the following code sets thecurrent record of CustomerTableOne to be the same as the current record ofCustomerTableTwo:CustomerTableOne.GotoCurrent(CustomerTableTwo);Tip If your application needs to synchronize datasets in this manner, put the datasets in adata module and add the unit for the data module to the uses clause of each unit thataccesses the tables.To synchronize datasets from separate forms, you must add one form s unit to theuses clause of the other, and you must qualify at least one of the dataset names withits form name.For example:CustomerTableOne.GotoCurrent(Form2.CustomerTableTwo);Using query-type datasetsTo use a query-type dataset,1 Place the appropriate dataset component in a data module or on a form, and set itsName property to a unique value appropriate to your application.2 Identify the database server to query.Each query-type dataset does thisdifferently, but typically you specify a database connection component:" For TQuery, specify a TDatabase component or a BDE alias using theDatabaseName property." For TADOQuery, specify a TADOConnection component using the Connectionproperty." For TSQLQuery, specify a TSQLConnection component using the SQLConnectionproperty." For TIBQuery, specify a TIBConnection component using the Database property.For information about using database connection components, see Chapter 23, Connecting to databases.3 Specify an SQL statement in the SQL property of the dataset, and optionallyspecify any parameters for the statement.For more information, see Specifyingthe query on page 24-43 and Using parameters in queries on page 24-45.24-42 Dev el oper s Gui deUs i n g q u e r y - t y p e d a t a s e t s4 If the query data is to be used with visual data controls, add a data sourcecomponent to the data module, and set its DataSet property to the query-typedataset.The data source component forwards the results of the query (called aresult set) to data-aware components for display.Connect data-aware componentsto the data source using their DataSource and DataField properties.5 Activate the query component.For queries that return a result set, use the Activeproperty or the Open method [ Pobierz całość w formacie PDF ]