|
项目描述: |
Many times it is neccessary to access databases without knowing the scheme of the database at design time.
Think that you are developing an application that supports ISE (Incremental Search and Edit) for a certain purpose.
The application reads a column of a database table to determine if there is any match to the letters that are allready typed in
a combo box. If it finds any then it displays the nearest one in the edit part of the combo.
When you do not know from where to get the information that should be displayed,or when the the source column
is being changed from time to time, the only solution is to bound your data columns at run time.
Of course you can also hard code the names of the columns, but you do not come far that way.
To solve a similar problem I developed a database connection class that can access any ODBC-database by using its DSN.
The CDBConnection is a class that takes care of all access to a database, regardless of the purpose. When it needs to fetch data
it uses Microsofts CDynamicBulkSet, and when it needs to edit data ( New, Update or Delete ) it uses CDynamicRow.
I used the CDynamicBulkSet here just to show several ways of accessing data dynamiclly and not at least to show also how to use multiple row fetch.
许多时候在不知道数据库设计时的方案的情况下也必须能够访问数据库。
考虑到你正在开发为某一特定目的支持ISE(逐渐增加的搜寻和编辑) 的应用程序。
应用程序读一个数据库表中的一列来决定是否有与已经敲入组合框中的字段相符合的记录。如果它发现了任何的一个,它将最近的一个显示在组合框中。
当你不知道该从哪里获得应该被显示的信息时候, 或当源列随时都在改变时,唯一的解决方法是在运行时绑定你的数据列。
Of course you can also hard code the names of the columns, but you do not come far that way.
为了解决同样的问题,我开发了一个数据库连接类,它可以通过使用数据库的DSN访问任何的ODBC数据库。
CDBConnection是一个负责数据库的所有连接的类而不管其目的。 当它需要取数据的时候
它使用微软的CDynamicBulkSet,当它需要编辑(新建,修改,删除
)时它使用 CDynamicRow。我使用CDynamicBulkSet只是为了展示动态存取数据几种方法而不是展示怎样获取多行数据。
来源: http://www.codeguru.com/mfc_database/DynData.shtml |
类别: |
|
发布者:
cbd002
|
|
最新发布源码包 |
软件包 |
版本号 |
日期 |
本地下载 |
DynData_demo |
 1.0  |
2004-04-19 |
下载 |
|
|