C++Builder 程序员博客
13 Nov
环境:frameA镶嵌在formA上,formB是另一个form
frameA上有一个DBGrid
formB上用了adoquery进行数据库存储
问题是
DBGrid怎么连接到adoquery进行数据库显示?是不是要额外加一个adoquery来负责DBGrid的显示?还有,不用DataSource行吗?觉得这个中间人麻烦,所以不想用他。
没有中间人介绍,无法直接恋爱!
作媒的
BCB中是这样说的
Use TDataSource to
provide a conduit between a dataset and data-aware controls on a form that enable display, navigation, and editing of the data underlying the dataset.
link two datasets in a master/detail relationship.
All datasets must be associated with a data source component if their data is to be displayed and manipulated in data-aware controls. Similarly, each data-aware control needs to be associated with a data source component in order for the control to receive and manipulate data.
Data source components also link datasets in master-detail relationships.
数据感知控件…必须有…
通过这个,你的DBGIRD才知道这一列写什么数据
/* 数据源呀,不然DBGrid从哪搞数据,当然你可以直接从Query中读取数据到某个 Grid中显示,那样你可以用它的胞弟控件TStringGrid,但是这样就需要你去 写数据读取代码,刷新代码,还有编辑,更新等代码。而如果你用DBGrid来帮 你,那么可以省去你很多的代码! */