DAO and MFC

MFC DAO数据库编程  10.3 MFC DAO数据库编程DAO(Database Access Object,数据访问对象)使用Microsoft Jet数据库引擎来访问数据库。MFC DAO封装了DAO的大部分功能,可以很方便地使用Microsoft Jet引擎访问数据库。本节就来介绍如何使用MFC DAO开发数据库应用程序。10.3.1 MFC DAO概述DAO适用于单系统应用程序或小范围本地分布 阅读详情

DAO and MFC

This article describes MFC's implementation of Microsoft Data Access Objects (DAO). Topics covered include:

  • How MFC Encapsulates DAO
  • Mapping of DAO objects to MFC classes
  • Key differences between MFC and DAO
  • Further reading about the MFC DAO classes
Note   Whether you use the MFC DAO classes or the MFC ODBC classes depends on your situation and your needs. For a discussion of the differences between the two and guidance on choosing one, see the article Database Topics (DAO).

How MFC Encapsulates DAO

The MFC DAO classes treat DAO much as the MFC classes for programming Windows treat the Windows API: MFC encapsulates, or "wraps," DAO functionality in a number of classes that correspond closely to DAO objects. Class CDaoWorkspace encapsulates the DAO workspace object, class CDaoRecordset encapsulates the DAO recordset object, class CDaoDatabase encapsulates the DAO database object, and so on.

MFC's encapsulation of DAO is thorough, but it is not completely one-for-one. Most major DAO objects do correspond to an MFC class, and the classes supply generally thorough access to the underlying DAO object's properties and methods. But some DAO objects, including fields, indexes, parameters, and relations, do not. Instead, the appropriate MFC class provides an interface, via member functions, through which you can access, for example:

  • The fields of a recordset object
  • The indexes or fields of a table
  • The parameters of a querydef
  • The relations defined between tables in a database

Mapping of DAO Objects to MFC Classes

The following tables show how DAO objects correspond to MFC objects. MFC Classes and Corresponding DAO Objects shows the MFC classes and the DAO objects they encapsulate. How MFC Manages DAO Objects Not Mapped to Classes shows how MFC deals with DAO objects that do not map directly to an MFC class.

Note   MFC now supports DAO 3.5. MFC DAO classes work either with DAO 3.0 or DAO 3.5, but have not been designed to take advantage of any new DAO 3.5 features, including ODBCDirect.

MFC Classes and Corresponding DAO Objects

ClassDAO objectRemarks
CDaoWorkspaceWorkspaceManages a transaction space and provides access to the database engine.
CDaoDatabaseDatabaseRepresents a connection to a database.
CDaoTableDefTabledefUsed to examine and manipulate the structure of a table.
CDaoQueryDefQuerydefUsed to store queries in a database. You can create recordsets from a querydef or use it to execute action or SQL pass-through queries.
CDaoRecordsetRecordsetUsed to manage a result set, a set of records based on a table or selected by a query.
CDaoExceptionErrorMFC responds to all DAO errors by throwing exceptions of this type.
CDaoFieldExchangeNoneManages exchange of data between a record in the database and the field data members of a recordset.

How MFC Manages DAO Objects Not Mapped to Classes

DAO objectHow MFC manages it
FieldObjects of classes CDaoTableDef and CDaoRecordset encapsulate fields and supply member functions for adding them, deleting them, and examining them.
IndexObjects of classes CDaoTableDef and CDaoRecordset encapsulate indexes and supply member functions for managing them. Tabledefs can add, delete, and examine indexes. Tabledefs and recordsets can set or get the currently active index.
ParameterObjects of class CDaoQueryDef encapsulate parameters and supply member functions for adding them, deleting them, examining them, and getting and setting their values.
RelationObjects of class CDaoDatabase encapsulate relations and supply member functions for adding them, deleting them, and examining them.

DAO Objects Not Exposed in MFC

MFC and DAO do not supply abstractions for some objects used within Microsoft Access: Application, Container, Control, Debug, Document, Form, Module, Report, Screen, and Section. If you create a Microsoft Access database and manipulate it from an MFC application, you can't access those objects through code.

MFC doesn't supply classes or interfaces to the DAO group and user objects — to work with DAO security, you must write your own code.

MFC also doesn't encapsulate DAO property objects, except that the MFC DAO classes do give you access to the properties of all exposed objects.

MFC does give you access to DAO's DBEngine object, through class CDaoWorkspace.

Accessing the Unexposed DAO Objects

The unexposed objects listed above can be accessed in two ways:

  • Outside the MFC classes by using the non-MFC C++ classes provided in the DAO SDK.
  • Inside the MFC classes by calling DAO directly through a DAO interface pointer supplied by one of the MFC classes. For information, see Technical Note 54.

Key Differences Between MFC and DAO

MFC's version of data access objects differs from the underlying structure of DAO in some ways.

How MFC Accesses the Database Engine

DAO has a DBEngine object that represents the Microsoft Jet database engine. The DBEngine object provides properties and methods you can use to configure the database engine.

In MFC, there is no DBEngine object. Access to important properties of the database engine is supplied via class CDaoWorkspace. To set or get these properties, call any of the static member functions of CDaoWorkspace. For more information, see the articles DAO Workspace: The Database Engine and DAO Workspace: Accessing Properties of the Database Engine.

MFC Flattening of the DAO Object Hierarchy

Because MFC doesn't supply a class for every DAO object, the effect is that the DAO object hierarchy is somewhat "flattened" in MFC. The main examples of this flattening are:

  • Putting access to the database engine in class CDaoWorkspace rather than in a database engine class.
  • Encapsulating DAO field, index, parameter, and relation objects inside the classes that represent their owning objects. For example, access to fields is encapsulated in classes CDaoTableDef and CDaoRecordset. For information, see the table How MFC Manages DAO Objects Not Mapped to Classes.

MFC and DAO Security

MFC does not encapsulate the DAO user and group objects in any way, which means that MFC doesn't provide DAO's security functionality.

You can still use DAO security from your MFC applications, but you will have to call DAO directly, using the m_pDAOWorkspace data member of class CDaoWorkspace. That member is a pointer to an interface that gives access to a DAO workspace object's methods and properties. For information about calling DAO directly, see Technical Note 54.

MFC does allow password protection via various MFC classes. For example, when you create a CDaoWorkspace object, you can specify a password to protect the database(s) that the workspace contains. To use this functionality, a SYSTEM.MDW file must be available to the database engine on the machine running your application. If no SYSTEM.MDW file is available to the database engine, your application cannot use any of the security features. For information about the SYSTEM.MDW file, see the topic "Permissions Property" in DAO Help.

Further Reading About the MFC DAO Classes

To learn more about using the MFC DAO classes, see the following articles (in the order listed here):

  • DAO: Writing a Database Application
  • DAO: Database Tasks
  • DAO: Creating, Opening, and Closing DAO Objects
  • DAO Workspace
  • DAO Database
  • DAO Database: Using Workspaces and Databases
  • DAO Recordset
  • DAO Record Field Exchange (DFX)
  • DAO Querydef
  • DAO Tabledef
  • DAO Workspace: Managing Transactions
  • DAO Collections
  • DAO External: Working with External Data Sources (primarily ODBC)
  • DAO Workspace: The Database Engine
  • DAO: Using DAO in DLLs
  • Exceptions: Database Exceptions
  • Record Views
Tip   From any of the MFC help topics in this documentation set, you can get to a topic called DAO: Where Is..., which helps you navigate online to the topics that you need. The topic is always available via the See Also button in the topic window.
vc6.0使用DAO访问access2000的问题 感觉DAO已经是一种比较旧的数据库技术,但我的一个同学还在使用VC6.0跟mfc的DAO类来操作access2000,并遇到了一个问题,就是程序运行时提示说“无法识别数据库格式”。查了一下原因,应该是这样的:VC6.0里面的mfc默认使用的是DAO3.5,而DAO3.5使用的数据库引擎是Jet3.5,Jet3.5操作access97是没有问题的,而操作access2000却不行,因为acces 阅读详情

相关推荐

mfc和mysql连接 dao_MFC,C与C++程序与MySql数据库连接 ——陈绍钦 csq

很多种方法在C++程序里利用数据库:ODBC、DB、DAO、ADO、API等,ODBC是传统的方法功能强大,ADO比较便捷,并逐渐代替了DAO。对于mysql数据库来说,其提供的API函数和PHP中mysqli函数相差不大,毕竟mysql是用c语言写的,可以说懂得了PHP和mysql的结合,就懂得了c++与mysql的结合。以下是C++程序里利用mysql数据库的简略说明。一、MySQL的安装可以...

weixin_33324197的博客 465

DAO简介(MFC)

1 DAO简介       DAO(数据访问对象)是一种应用程序编程接口(API),存在于微软的Visual Basic中,它允许程序员请求对微软的Access数据库的访问。DAO是微软的第一个面向对象的数据库接口。DAO对象封闭了Access的Jet函数。通过Jet函数,它还可以访问其他的结构化查询语言(SQL)数据库。在VC中,它是从Visual C++4.0版开始引入的。 2 D

MannHello的专栏 2235

深入理解MFC数据库编程:ODBC与DAO技术

本文深入探讨了MFC(Microsoft Foundation Classes)在数据库编程中的应用,特别是ODBC(Open Database Connectivity)和DAO(Data Access Objects)API的使用。通过实例分析,展示了如何利用MFC的文档/视图架构与ODBC和DAO包装类来创建一个地址簿应用程序,包括获取数据、更新应用程序变量、以及如何通过AppWizard简化开发过程。

weixin_36019375的博客 359

MFC DAO编程总结

一半情况下,并不需要直接使用CDaoDatabase对象,因为CDaoRecordSet对象可以是实现大多数功能,但是,在进行事务(Transaction)处理时,CDaoDatabase就起到关键作用。使用CDaoDatabase构造一个对象,并调用Open成员函数打开数据源的连接,接着构造CDaoRecordSet对象以操作连接的数据源,并向CDaoDatabase对象传递记录集构造程序指针。注意:MFC DAO仅用来支持Access数据库,应用范围相对固定。

jiandaxiami的博客 289

MFC数据库编程:ODBC和DAO的封装与实现

本章详细介绍了如何使用MFC提供的ODBC和DAO API封装类来创建一个通讯录应用程序。通过实例演示了如何将数据绑定到应用程序,并使用MFC AppWizard创建数据绑定。本章内容涵盖了从设置数据源、创建数据支持到利用MFC的文档/视图架构实现数据与视图的绑定。

weixin_36019375的博客 470

全面掌握MFC在C++中的应用与技巧

本文还有配套的精品资源,点击获取 简介:《深入浅出MFC(C++)》旨在提供对微软基础类库(MFC)的全面解析,帮助开发者高效开发Windows应用程序。书中详尽介绍了MFC的基础结构、框架类、消息处理机制、文档/视图架构、DLL支持、数据库编程、国际化、异常处理和网络编程等关键知识点,致力于提升开发者在这些领域的专业技能。 1. MFC基本概念与初始化 1...

weixin_35705784的博客 2693

MFC中使用DAO来打开数据库

最近在学习MFC中数据库的使用,在之前写过一篇使用使用Access技术连接数据库。在这个项目中打开的是.mdb数据库文件。ODBC是数据库的连接接口,他不管连接是何种数据库,在程序运行过程中都会提供选定数据库的引擎。点击打开MDB文件后,选择要打开的MDB文件,然后显示数据库中的表,如图所示。这个例子的思路是:在文档类中打开数据库,并读取其中的数据,然后保存起来。这个例子中其中CDAOTestView继承于一个自定义的CRowView,这个CRowView的试图类是一个纯虚类,负责数据的处理和显示。

weixin_45144862的博客 1294

MFC DAO编程函数一览

这是我自己总结的MFC DAO编程中,CDaoWorkspace CDaoDatabase CDaoTableDef CDaoQueryDef CDaoRecordset五个类的成员函数,比较全。

C++连接SQL SERVER 数据库方式

1、ODBC ODBC(Open DataBase Connectivity)开放数据库互联。是由微软主导的数据库链接标准; ODBC是一个访问数据库的底层接口,想要使用ODBC必须提供驱动,sqlserver 提供SQL Server Native Client ODBC driver来支持ODBC接口。 只能用户关系型数据库,很难用于对象数据库及其他非对象数据库。 ODBC访问sqls...

weixin_34080903的博客 1322

演示如何用MFC和DAO(数据访问对象)写一个CGI扩展服务器,程序动

演示如何用MFC和DAO(数据访问对象)写一个CGI扩展服务器,程序动态生成一个网页显示数据库中的前三条记录(8KB)

mfc DAO连接access数据库

mfc DAO连接access数据库 可添加,删除记录!

SQL Server MFC DAO类和MFC ODBC类

转自:http://www.verybc.com/a/shujuku/20091125/9828.html时间:2009-11-25 00:26来源:作者:点击:347次内容概要:大多数 mfc 开发人员都熟悉开放式数据库连接 (odbc) 数据库类 - 它们早在三年半以前就出现了。在 mfc 4.2 中,对这些类有一些重要的 大多数 mfc 开发都熟悉开放式数据库连接 (odbc) 数据库类 - 它们早在三年半以前就出现了。在 mfc 4.2 中,对这一些类有一些很重要的改进。<br />身为 c++ 开

Nicholas的专栏 QQ1295794532 1129

LiveKit 本地部署实战:从零搭建安全实时通信环境(Caddy+HTTPS)

本文详细介绍了如何从零开始搭建LiveKit本地部署环境,结合Caddy服务器实现HTTPS安全通信。通过环境准备、证书生成、服务配置到前端客户端集成的完整流程,帮助开发者快速构建实时音视频应用,特别适合需要安全实时通信的场景。

weixin_29227585的博客 681

mfc和mysql连接 dao_DAO简介(MFC) .

1 DAO简介DAO(数据访问对象)是一种应用程序编程接口(API),存在于微软的Visual Basic中,它允许程序员请求对微软的Access数据库的访问。DAO是微软的第一个面向对象的数据库接口。DAO对象封闭了Access的Jet函数。通过Jet函数,它还可以访问其他的结构化查询语言(SQL)数据库。在VC中,它是从Visual C++4.0版开始引入的。2 DAO和ODBC的比较2.1 ...

weixin_35064481的博客 294

CPU核心、die和package的区别:从硬件小白到高手的进阶指南

本文深入浅出地解析了CPU核心、Die与Package的核心概念与区别,是硬件爱好者从入门到精通的实用指南。文章从硅晶圆制造讲起,阐述了物理核心与逻辑线程(如超线程技术)的工作原理,并详细介绍了封装(Package)的作用与多Die模块化设计。最后,结合实际应用场景,提供了选购、性能解读与优化调优的实用建议。

pz89012345的博客 204

避坑指南:Qt5.14.2 ARM交叉编译中那些你可能遇到的‘坑’及解决方案

本文深度解析了Qt 5.14.2在ARM架构上进行交叉编译的完整流程与常见难题。重点阐述了如何精准匹配交叉编译器与目标板环境、正确配置sysroot以及使用configure参数的艺术,并针对编译过程中的头文件缺失、链接错误等典型“坑”提供了经过验证的解决方案,旨在帮助开发者成功构建适用于嵌入式设备的Qt运行时库。

weixin_29279101的博客 355

java中dao_java中的Dao类是什么意思?

展开全部DAO(Data Access Object)数据访问对象是一个面向对象的数据库接口,它显露了 Microsoft Jet数据库引擎(由62616964757a686964616fe58685e5aeb931333366303062 Microsoft Access 所使用),并允许 Visual Basic 开发者通过 ODBC 像直接连接到其他数据库一样,直接连接到 Access ...

weixin_36329071的博客 4321

【AIGC】人工智能训练师(高级)考试题库-橙点同学

例如,在嘈杂的环境中进行声音转文字,即使是优秀的模型也可能会出现一些错误,但这并不意味着该模型本身质量差,在其他较为理想的环境下,它可能会有很好的表现。例如,在一些语音应用和系统中,会使用SSML来实现对语音合成的精细控制,如调整语速、语调、音量等,而这些应用和系统的开发往往会遵循W3C的相关标准和框架,其中就包括SSML这一语音合成标记语言。例如,在语音识别等场景中,像“去火车站怎么走”这样的语音指令,没有其他嘈杂的背景声音或模糊不清的表述,就属于无噪音的数据,有利于系统准确地进行处理和分析。

RisunJan的博客 9922

MFC DLL——Regular DLL and Extension DLL

2  MFC DLL——扩展的和正规的MFC的AppWizard可以让我们创建MFC库支持的两种DLL:扩展的DLL和正规的DLL。这两种类型的区别是什么呢?说明:当然,Developer Studio也让我们创建纯的、与MFC库无关的Win32 DLL,就像它让我们创建与

delphiwcdj的专栏 5009

保姆级教程:在Ubuntu 20.04上从源码编译Apollo自动驾驶平台(含GPU环境配置)

本文提供了一份详细的Ubuntu 20.04上从源码编译Apollo自动驾驶平台的保姆级教程,包括GPU环境配置、Docker部署和编译构建等关键步骤。通过实战经验和避坑指南,帮助开发者高效完成Apollo平台的编译和验证,适用于自动驾驶技术研究和应用开发。

weixin_30876945的博客 409

ResNet改进(7):添加 SK注意力机制

实现 SK 注意力机制。

2401_82355416的博客 732

使用ODBC还是DAO

从 Visual C++ .NET 起,Visual C++ 环境和向导不再支持 DAO(不过提供了 DAO 类,仍可供您使用)。Microsoft 建议对新项目使用 OLE DB 模板或 ODBC。DAO 只应用于维护现有的应用程序。 使用哪一

652

1️⃣ Coze智能体基础入门教学(2025年全新版本)

不妨设想一下,倘若我们能够打造出一个数字助手,它不但能精准洞悉我们的需求,更可以独立思索、学习以及付诸行动,这便是 AI Agent 的基础理念。它恰似计算机世界里的 “智慧精灵”,能够感知周遭环境、做出判断并采取行动。AI Agent 的发展之路精彩纷呈。它走过了三个重要阶段:起初,它犹如一个被规则束缚的机器人,只能按预设好的指令开展工作。接着,它学会运用统计学方法,通过分析数据来做决策,变得越发灵活。到如今,凭借深度学习技术,它已经能够像人类一样去学习复杂的任务了。

李同学Lino的博客 4087

DAO在MFC中的应用实例

本文介绍使用MFC DAO访问数据库的一个实例,其中实例来源于网络。  实例同样实现了对数据库的基本操作:添加、修改、删除和遍历。与ODBC实例中不同的是,ODBC使用过程中添加了一个从CRecordset派生而来的CBook类,负责成员数据与数据表字段的关联,而本实例则是直接使用CDaoRecordset类。无论是使用ODBC还是DAO访问数据库都可以使用这两种方法,本实例采用后者来实现

MannHello的专栏 1203

边缘AI工业落地:YOLO26-Seg + RK3588 NPU 极致部署(低功耗+实时实例分割,工业场景全覆盖)

本次实战汇总了「YOLO26-Seg+RK3588 NPU」工业边缘部署中最常见、最致命的8个坑点,所有坑点均来自真实工业项目,解决方案均为零代码/一键操作,无需复杂配置,能让你少走90%的弯路,节省大量时间,必看必记!❌ RKNN转换报错「算子不支持/模型加载失败」→ ✅ 导出ONNX时必须指定opset=12,重新导出即可,RK3588唯一兼容版本;❌ 分割mask错位/轮廓模糊 → ✅ 导出ONNX时加,并保证RKNN的归一化参数与YOLO26一致,零代码修复;

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1719

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

【MFC-数据库无法对DAO/Jet db引擎进行初始化】2020-11-02

问题1描述:当编译运行MFC后,软件提示如下错误: 原因分析: 解决方法: 手动注册DAO350.DLL和MSJET35.Dll

千帆少年靓 4063

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

上一篇: 10.9 自动注册DSN和创建表
下一篇: ^_-诚征BLOG友情连接
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值