Pages

Monday 10 February 2014

How to open and close datasets in Delphi? Difference between Open Method and Active Property in Delphi

How to open and close datasets in Delphi? Difference between Open Method and Active Property in Delphi

To read or write data in a dataset in Delphi, an application must first open it. You can open a dataset in two ways:

1. Open method: Call the Open method for the dataset at run time.
2. Active Property: Set the Active property of the dataset to True, either at design time in the Object Inspector, or in code at run time.

After performing operations on datasets, you must close them. You can close a dataset in two ways:

1. Close method: Call the Close method for the dataset at run time.
2. Active Property: Set the Active property of the dataset to False, either at design time in the Object Inspector, or in code at run time.

For example, if you have dsSample dataset in your code. You can open it like:

dsSample.Open;
dsSample.Active := True;

and close it like:

dsSample.Close;
dsSample.Active := False;

Difference between Open and Active

1. Open is a methods and Active is a property.

2. Open method is generally used at runtime while Active property is used to open dataset at design time. Active deals with Object Inspector. Without having Active property you wouldn't be able to open the dataset at design time because you cannot publish method to the Object Inspector.

3. Open method is much more readable than evaluating what's assigned to the Active property.

4. Active property calls Open method internally.

No comments:

Post a Comment

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.