⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right19-3.htm

📁 Visual C++面向对象程序设计教程(配套习题资源)
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>第 19 章</title>
<base target="rbottom">
<style>
<!--
.右标题   { font-size: 10pt; color: #000080; text-indent: 0; margin: 0 }
.右内容   { font-size: 10pt; text-align: left; text-indent: 0; line-height: 100%; margin: 
               0 }
-->
</style>
</head>

<body>

<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><span style="position: absolute; left: 4; top: -8"><img border="0" src="1.gif" width="63" height="70"></span></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                                                
&nbsp;&nbsp;&nbsp; <span style="background-color: #CCFF99">第 19 章</span><span style="background-color: #CCFF99">&nbsp;                                                     
</span>&gt;<span style="background-color: #CCFF99"> 第 3 节 </span>&gt;<span style="background-color: #CCFF99">    
19.3 </span><span style="background-color: #CCFF99">DAO数据库程序设计</span></p>                  
<hr color="#008000" size="1">

<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">DAO<font LANG="ZH-CN">和</font>ODBC<font LANG="ZH-CN">不同,不需要设计数据源即可访问数据库,比</font>ODBC<font LANG="ZH-CN">更灵活使用更广泛。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">1.  
<font LANG="ZH-CN">什么是</font>DAO</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">DAO<font LANG="ZH-CN">(</font>Database  
Access Object<font LANG="ZH-CN">)使用</font>Microsoft Jet<font LANG="ZH-CN">数据库引擎来访问数据库。</font></font></p> 
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">与</font>ODBC<font LANG="ZH-CN">一样,</font>DAO<font LANG="ZH-CN">提供了一组</font>API<font LANG="ZH-CN">供编程使用。</font>MFC<font LANG="ZH-CN">也提供了一组</font>DAO<font LANG="ZH-CN">类,封装了底层的</font>API<font LANG="ZH-CN">,从而大大简化了程序的开发。利用</font>MFC<font LANG="ZH-CN">的</font>DAO<font LANG="ZH-CN">类,用户可以编写独立于</font>DBMS<font LANG="ZH-CN">的应用程序。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(1)  
DAO和ODBC的相似之处</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN">①</font> 
<font LANG="ZH-CN">二者都支持对各种</font>ODBC<font LANG="ZH-CN">数据源的访问。</font></font></p> 
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">②</font> 
DAO<font LANG="ZH-CN">提供了与</font>ODBC<font LANG="ZH-CN">功能相似的</font>MFC<font LANG="ZH-CN">类。</font></font></p> 
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">③</font> 
AppWizard<font LANG="ZH-CN">和</font>ClassWizard<font LANG="ZH-CN">对使用</font>DAO<font LANG="ZH-CN">和</font>ODBC<font LANG="ZH-CN">对象的应用程序提供了类似的支持。</font></font></p> 
<p ALIGN="justify" style="line-height: 100%; margin-top: 10; margin-bottom: 0"><font LANG="ZH-CN" size="2">(2)  
DAO的优点</font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">DAO<font LANG="ZH-CN">可以通过</font>ODBC<font LANG="ZH-CN">驱动程序访问</font>ODBC<font LANG="ZH-CN">数据源。但</font>DAO<font LANG="ZH-CN">是基于</font>Microsoft  
Jet<font LANG="ZH-CN">引擎的,通过该引擎,</font>DAO<font LANG="ZH-CN">可以直接访问</font>Access<font LANG="ZH-CN">、</font>FoxPro<font LANG="ZH-CN">、</font>dBASE<font LANG="ZH-CN">、</font>Paradox<font LANG="ZH-CN">、</font>Excel<font LANG="ZH-CN">等数据库。</font>CDaoDatabase<font LANG="ZH-CN">类可以直接与这些数据库进行连接,而不必在</font>ODBC<font LANG="ZH-CN">管理器中注册</font>DSN<font LANG="ZH-CN">。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">由于</font>DAO<font LANG="ZH-CN">可以访问</font>ODBC<font LANG="ZH-CN">数据源,下面几条可以作为</font>DAO<font LANG="ZH-CN">替代</font>ODBC<font LANG="ZH-CN">的理由:</font></font></p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">① 
在某些情况下可以获得更好的性能,特别是在访问</font>Microsoft  
Jet<font LANG="ZH-CN">(</font>.MDB<font LANG="ZH-CN">)数据库时。</font></font></p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">② 
与</font>ODBC<font LANG="ZH-CN">兼容</font></font></p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">③  
</font>DAO<font LANG="ZH-CN">允许数据有效检查</font></font></p>
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">④</font> 
DAO<font LANG="ZH-CN">允许用户说明表与表之间的关系</font></font></p> 
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font size="2"><font LANG="ZH-CN">当然,</font>DAO<font LANG="ZH-CN">的出现并不意味着</font>ODBC<font LANG="ZH-CN">已经过时了。如果用户的工作必须严格限于</font>ODBC<font LANG="ZH-CN">数据源,尤其是在开发</font>Client/Server<font LANG="ZH-CN">结构的应用程序时,用</font>ODBC<font LANG="ZH-CN">有较好的性能。</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2">2.  
<font LANG="ZH-CN">程序举例</font></font></p>
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font size="2"><font LANG="ZH-CN"><a href="example19-2.htm" target="_blank">【例</a></font><a href="example19-2.htm" target="_blank">19-2<font LANG="ZH-CN">】</font></a><font LANG="ZH-CN">将邮编和区号数据库内容以表格的形式显示在屏幕上,如图</font>19-13<font LANG="ZH-CN">所示,数据库名为</font>ybqh.mdb<font LANG="ZH-CN">。</font></font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left"> </p>

<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>            

<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp; <span style="position: absolute; left: 31; top: 531"><a href="right19-2.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="position: absolute; left: 502; top: 531"><a href="right19-4.htm" target="_self"><img border="0" src="rightd2.gif" width="124" height="63"></a></span></p>                      

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -