在QUERY中的Close和CloseDatabase有何区别(10分)

  • 主题发起人 主题发起人 srs
  • 开始时间 开始时间
Delphi Help:
CloseDataBase
Closes a database connection associated with the database session.
Closes a database connection associated with the database session.

procedure CloseDatabase(Database: TDatabase);

Description

Call CloseDatabase to close a persistent database connection, or to close and free a temporary database connection. Database specifies the name of the database component for which to close the connection.

CloseDatabase decrements the specified database component抯 reference count, and then, if the reference count is zero and the database component抯 KeepConnection property is False, CloseDatabase either frees a temporary database component or closes the connection for a persistent database component.

Note: Calling CloseDatabase for a persistent database component does not close the connection. To close a connection for a persistent database component, call the database component抯 Close method directly.

Temporary database components are closed automatically when the last dataset associated with the database component is closed, but an application can call CloseDatabase prior to that time to force closure. Closing a connection established by a temporary database component does not free the component if the session抯 KeepConnections property is True (the default). To free temporary database components after closing their connections call DropConnections method of the session.

TQuery.Close
Closes a dataset.

procedure Close;

Description

Call Close to set the Active property of a dataset to False. When Active is False, the dataset is closed; the dataset cannot read data from or write data to the database.

An application must set Active to False before changing other properties that affect the status of the database or the controls that display data in an application. For example, to change the DataSource property for a dataset, Active must first be set to False, ensuring that the dataset is closed. Setting Active to False puts the dataset into dsInactive state and closes the BDE cursor.
 
请先理解TDataSet和TDatabase的区别,
Close和CloseDatabase的差别就清楚了。
 
接受答案了.
 
后退
顶部