TDataset.close()在Delphi中的确切作用是什么? [英] What is the exact effect of TDataset.close() in Delphi?

查看:43
本文介绍了TDataset.close()在Delphi中的确切作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么建议按以下方式在Delphi中处理sql查询?

  dataset.close();//?????数据集.sql.clear();//旧的sql查询被删除dataset.sql.add('您的sql-query');//在此处将查询字符串添加到您的sql-objectDataset.open();//在这里,您的sql查询开始工作 

是否可以通过关闭sql-Object每次定义默认状态,从而删除由先前sql-query产生的先前数据集?

解决方案

打开数据集时,假设数据库/驱动程序支持此功能,它将启用活动连接.一些数据库连接保持活动状态,而其他则不是.对于这种情况, Open 过程启用与数据库的开放连接,在这种情况下,您可以使用数据集动态编辑该数据.因此,当您 Close 数据集时,通常会关闭打开的数据集.请记住, TDataset 被继承为其他更具体的类型,并且其中许多程序都需要 Open / Close 过程.

关闭数据集也会使其中包含的数据无效,因此也不再提供该数据.您的查询将保留在那里,但数据将不再可用于读取/写入.

Why it is recommended to process a sql-query in Delphi in the following way?:

dataset.close();     //  ?????
dataset.sql.clear(); // old sql-query gets deleted

dataset.sql.add('your sql-query'); // here a query-String is added to your sql-object

dataset.open();  // here your sql-query starts to work

Can it be that closing of a sql-Object defines everytime a default state by which the former dataset resulting from the former sql-query is deleted?

解决方案

When you open a dataset, it enables an active connection, assuming your database/drivers support this. Some database connections are keep-alive, others aren't. For the ones which are, the Open procedure enables an open connection with the database, in which case you can dynamically edit that data using the dataset. So when you Close a dataset, this is typically closing what was opened. Keep in mind that the TDataset is inherited into other more specific types, and the Open / Close procedures are required for many of those.

Closing a dataset also invalidates the data contained within it, therefore is no longer providing that data as well. Your query will stay there, but the data will no longer be available to read/write.

这篇关于TDataset.close()在Delphi中的确切作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆