在基于 mfc 对话框的应用程序中添加 sql 数据库 [英] Add sql database in mfc dialog based application

查看:58
本文介绍了在基于 mfc 对话框的应用程序中添加 sql 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 MFC 对话框的项目,现在我想为该项目添加数据库.我不知道该怎么做.谁能提供有用的链接?

I have a MFC dialog based project,Now I want to add database with that project. I have no idea how to do this. can anybody provide the useful link?

实际上,当我创建一个新的基于对话框的 MFC 项目时,数据库支持是隐藏的.所以我想问一下

Actually when I create a new dialog based MFC project, the database support is hide. So I want to ask that

MFC 对话框基础项目是否支持数据库

当我创建新的基于 Dialog 的 MFC 项目时

When I create new Dialog based MFC project

隐藏数据库支持.

推荐答案

最好直接使用 CDatabaseCRecordset 类打开数据库,进行读/写到表,或使用不同的 CRecordset 对象调用 SQL.

You should better directly use CDatabase and CRecordset classes to open to the database, and read/write to the tables, or call SQL using different CRecordset objects.

您只需要一个 CDatabase 对象,并将其附加到不同的 CRecordset 实例(一次一个).您可以直接使用CRecordset 并在循环中使用GetFieldValue 方法(由IsEOF 方法控制).或者你可以继承 CRecordset 并实现 DoFieldExchange.参见此处.

You need only one CDatabase object, and attach it to different CRecordset instances (one at a time). You may directly use CRecordset and use GetFieldValue method in a loop (controlled by IsEOF method). Or you may inherit from CRecordset and implement DoFieldExchange. See here.

这篇关于在基于 mfc 对话框的应用程序中添加 sql 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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