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

📄 h20000324-16.htm

📁 对于学习很有帮助
💻 HTM
字号:
<html><head><script language="JavaScript">	function reset(){   for ( var i=0; i < document.Form1.elements.length; i++ )     { document.Form1.elements[i].options[0].selected=true }}function going(url){        parent.location=url;        reset();}</script><style><!--A:link {text-decoration: none; color: #000000; font-family: 宋体}A:visited {text-decoration: none; color: #000000; font-family: 宋体}A:active {text-decoration: none; font-family: 宋体}A:hover {text-decoration: underline:#ffffff; color: #ff0000}body,table {font-size: 9pt; font-family: 宋体}.H1 {font-size: 9pt ; line-height:9pt; align=center}.ourfont {font-size: 9pt ; line-height:9pt; }.ourfont1 {font-size: 9pt ; line-height:9pt; }--></style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>在Delphi中利用Tbatch组件完成数据批处理</title></head><body topmargin="0" leftmargin="0"><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody>  <tr>    <td><p class="content4"><span class="font"><img border="0" height="3" src="../../soft/pix.gif" width="700"></span></td>  </tr></tbody></table></center></div><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody>  <tr>    <td bgColor="#3399ff" width="658"><p class="ourfont"><span class="font">&nbsp; </span><a style="text-decoration: none; color: rgb(255,255,255)" href="../os/H00705-2.htm">操作系统</a><font color="#FFFFFF"><span class="font"><span> |</span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../image/H00705-14.htm">图像处理</a><font color="#FFFFFF"><span>|<span class="font"> </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../autoCAD/H00705-19.htm">辅助设计</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../data/H00705-18.htm">数     据 库</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="H00706-1.htm">高级编程</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../netuse/H00705-20.htm">网络应用</a><font color="#FFFFFF"><span><span class="font"> | </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../webpage/H00705-21.htm">网页制作</a><font color="#FFFFFF"><span><span class="font"> |</span></span></font> <a style="color: rgb(255,255,255); text-decoration: none" href="../technic/H00706-3.htm">技术交流     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </a><a style="color: rgb(255,255,255); text-decoration: none" href="http://202.100.13.77/clslyb/default.asp?clsid=jiaoc"><font color="#FFFFFF"><strong>过客留言</strong></font></a></td>    <td bgColor="#3399ff" width="32"><p align="center" class="ourfont"><a href="mailto:net@163.sn.cn"><img src="../../soft/email.gif" alt="email.gif (493 字节)" border="0" WIDTH="20" HEIGHT="19"></a></td>  </tr></tbody></table></center></div><div align="center"><center><table border="1" cellSpacing="1" width="700" bordercolor="#3399FF"><tbody>  <tr>    <td align="left" bgColor="#FFFFFF" vAlign="top" width="700" bordercolor="#0000FF" bordercolorlight="#0000FF" bordercolordark="#0000FF"><p class="ourfont"> </p>    <p align="center">在Delphi中利用Tbatch组件完成数据批处理<br>    <br>    军械工程学院五系研究生队 王俊 </p>    <p>----在数据库应用系统中,常常要对数据进行成批的如追加、删除、更改等操作,这种批量操作在专门的数据库开发工具如VFP中用APPEND、COPY命令带上相应的命令子句就能轻易完成。但在其它开发工具中并没有类似的命令,而是提供能完成类似功能的控件或对象,如在PowerBuilder中就是利用Pipe     Line(数据管道)来完成两个或同构或不同构的表之间的数据批处理。本文要介绍的是Delphi中用来完成数据批处理任务的组件TBatchMove。<br>    <br>    TBatchMove组件能够:<br>    <br>    将一个数据集中的数据追加到一个表中。<br>    从一个表中删除满足条件的记录。<br>    按旧表结构生成一个新表,若欲生成的新表已存在,则覆盖。<br>    <br>    ----具体的操作要通过设置TBatchMove的Mode属性后再调用Execute方法来完成。为举例说明问题,我们在别名<br>    数据库DBDEMOS中先创建两个dBase格式的表Test1.dbf和Test2.dbf。二者的结构如下表:<br>    <br>    Test1.dbf Test2.dbf<br>    Name C 10 Name C 10<br>    Code C 3 Code C 3<br>    <br>    ----其中表Test2.dbf在字段code上建立有唯一索引。同时假设表单中已有两个TABLE控件Tsource和Tdest和一个TbatchMove组件batchmove1。Tsource和Tdest的DatabaseName属性均设为DBDEMOS。batchmove1的source属性设为Tsource,destination属性设为Tdest。<br>    <br>    ----在使用TbatchMove组件时,必须牢记:所有的操作都是以源表为标准针对目的表进行的,下面就分别举例说明TbatchMove的各种操作模式:<br>    <br>    batAppend     追加模式将源表中的数据追加到目的表中,目的表必须事先存在。<br>    这是缺省模式。<br>    batchmove1.source=Tsource;<br>    batchmove1.destination=Tdest2;<br>    batchmove1.Mode:=batCopy;<br>    batchmove1.Execute;<br>    batUpdate     更新模式用源表中匹配目的表的记录替换目的表中的相应记录。目的表必须事先存在且有一已定义的索引用来匹配源表中的记录。<br>    Tdest.IndexFieldNames:=`code`;&nbsp;<br>    batchmove1.source=Tsource;&nbsp;<br>    batchmove1.destination=Tdest ;&nbsp;<br>    batchmove1.Mode:=batUpdate;&nbsp;<br>    batchmove1.Execute;&nbsp;<br>    batAppendUpdate     追加更新模式如果源表中有与目的表匹配的记录,则替换目的表记录,否则,直接追加到目的表中。目的表必须事先存在且有一已定义的索引用来匹配源表中的记录。<br>    Tdest.IndexFieldNames:=`code`;&nbsp;<br>    batchmove1.source=Tsource;&nbsp;<br>    batchmove1.destination=Tdest ;&nbsp;<br>    batchmove1.Mode:=batAppendUpdate;&nbsp;<br>    batchmove1.Execute;&nbsp;<br>    batCopy     拷贝模式按源表结构生成新表,源表中的数据同时拷贝到目的新表中。如果要生成的新表已存在,则覆盖。<br>    //按Test1.dbf生成新表xxx.dbf<br>    //如果不指定扩展名dbf,生成的新表将是Paradox格式的xxx.db。&nbsp;<br>    Tdest.TableName:=`xxx.dbf`;&nbsp;<br>    batchmove1.source=Tsource;&nbsp;<br>    batchmove1.destination=Tdest ;&nbsp;<br>    batchmove1.Mode:=batCopy;&nbsp;<br>    batchmove1.Execute;&nbsp;<br>    batDelete     删除模式删除目的表中与源表匹配的记录。目的表必须事先存在且有一已定义的索引用来匹配源表中的记录。<br>    Tdest.IndexFieldNames:=`code`;&nbsp;<br>    batchmove1.source=Tsource;&nbsp;<br>    batchmove1.destination=Tdest ;&nbsp;<br>    batchmove1.Mode:=batDelete;&nbsp;<br>    batchmove1.Execute;&nbsp;<br>    <br>    ----TBatchMove还有一个重要属性ChangedTableName,在实际运用中,通过指定ChangedTableName属性可以创建一个Paradox表,该表用来保存目的表中被更改数据的原始备份,有了这个备份表就可以确保恢复目的表中的数据。<br>    <br>    ----顺便提一句,如果要删除某一个表中的全部记录,可以采用Table组件的EmptyTable方法,例如Tdest.EmptyTable将清空Tdest所指定的表test2.dbf。<br>    <br>    ----本文中是以同构的dbf表进行的示例,在实际运用中,源表和目的表可能同购,也可能异构,异构时,Delphi的BDE会自动进行类型和长度上的转换,具体类型间的关系可以有关BDE的帮助。本文中各种操作模式的实际结果均可以从Delphi的Database     Desktop中查看到。 </td>  </tr></tbody></table></center></div><hr align="center" SIZE="1" width="700"><p align="center" class="ourfont"><span><span><font color="#000000">&nbsp; <a style="color: rgb(0,0,0); text-decoration: none" href="../../soft/network/index.htm">互联网络</font><font color="#FFFFFF"> </font></a><font color="#000000">|</span></span><a href="../../soft/system/index.htm" style="color: rgb(0,0,0); text-decoration: none">系统工具</a><span>|<span> <a href="../../soft/tools/index.htm" style="color: rgb(0,0,0); text-decoration: none">实用工具</a> | <a href="../../soft/multimedia/index.htm" style="color: rgb(0,0,0); text-decoration: none">媒体工具</a> | <a href="../../soft/image/index.htm" style="color: rgb(0,0,0); text-decoration: none">图形图像</a> | <a href="../../soft/game/index.htm" style="color: rgb(0,0,0); text-decoration: none">游戏娱乐</a> | </span><a href="../../soft/usesoft/index.htm" style="color: rgb(0,0,0); text-decoration: none">软件<span>使用</a></font><font color="#FFFFFF"> |</font>&nbsp; </span></span></p><hr align="center" SIZE="1" width="700"><font color="#FFE8BB"><p align="center" class="ourfont"></font><font color="#000000"><span><span>&copy;&nbsp;Copyright 2000 </span></span>陕西公用计算机互联网信息中心<span><span> 版权所有 </font></p></span></span><p align="center" class="ourfont"><font color="#000000"><span><span>本站制作维护by <a style="color: rgb(0,0,0)" href="mailto:haiyuan@163.sn.cn">HAIYUAN</a></span></span></font></p><p align="center" class="ourfont"><font color="#000000"><span><span>电话:(029)8371051 8371055 8371049 联系信箱:<a href="mailto:net@163.sn.cn">net@163.sn.cn</a></span></span></font></p></body></html>

⌨️ 快捷键说明

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