ADO三大对象的属性、方法、事件及常数(三)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 joo 的 blog

ado三大对象的属性、方法、事件及常数(三) recordset对象 属性 属性名称 数据类型和用途 absolutepage 可读写long类型,要么是设置或返回当前记录所处的页面序号,要么是一个positionenum常数,见absolutepage用到的常数。在获取或设置absolutepage的值之前,必须先设定pagesize的值。absolutepage是从1开始计数的。如果当前记录位于第一页时,absolutepage的返回值为1,对absolutepage设置将使当前记录指针指向指定页的第一条记录。 absoluteposition* 可读写的long类型(从1开始计数),设置或返回当前记录年处的位置。absoluteposition的最大取值是recordcount属性的值。 activecommand 可读写的string类型,recordset所关联的先前打开的command对象名称 activeconnection 指针类型,指向recordset所关联的先前打开的connection对象,或指向一条完整有效的connectionstring串值。 bof* 只读boolean类型,若为true,表明记录指针已位于recordset第一条记录之前,并且没有了当前记录 bookmark* 可读写variant类型,返回对特定记录的引用或使用一个bookmark值使记录指针指向特定记录 cachesize* 可读写long类型,指定本地cache中所存的记录条数,最小(默认值)为1。若增加了cachesize的值,则在流动recordset以获取更多记录时,能减少与服务器的通信次数。 cursorlocation 可读写long类型,指定可流动游标的位置,即cursortype是位于客户端还是位于服务器端,见cursorlocation用到的常数。默认值是使用ole db数据源提供的游标。 cusrsortype* 可读写long类型,指定recordset游标的类型,见cursortype用到的常数,默认值是forward-only游标 datamember 指针类型,指向关联的dataenvironment.command对象 datasource 指针类型,指向关联的dataenvironment.connection对象 editmode* 只读long类型,返回recordset的编辑状态,见editmode用到的常数 eof* 只读boolean类型,若为true,表明记录指针已超出recordset的最后一条记录,并且没有了当前记录。 filter* 可读写variant类型,要么是一条件表达式(一条有效的sql where子句但又不出现保留字where),要么是指向特定记录的bookmark数组,要么是一个filter常数,详见filter用到的常数。 locktype* 可读写long类型,指定打开recordset所使用的记录锁定方法。默认值是只读,对应于forward-only游标的只读特性。见locktype属性用到的常数。 marshaloptions 可读写long类型,指定客户端改动后,应返回哪个记录集合,此属性仅适合于不常见的ador.recordset对象,此对象是rds.ador.recordset对象成员之一。 maxrecords* 可读写long类型,指定select查询或存储过程返回的最大记录条数,默认值为0,即全部返回 pagecount 只读long类型,返回recordset所有的页数,必须设定了pagesize的值,pagecount的返回值才是真正有意义的。如果recordset不支持pagecount属性,则返回值为-1 pagesize 可读写long类型,设置或返回一个逻辑页所包含的记录条数。使用逻辑页可把大的recordset分解为多个易处理的小部分。通常的做法是把pagesize设为datagrid、msflexgrid或层次型的flexgrid控件所能显示的记录条数。pagesize和锁定jet(2k)或锁定sql server(6.5版及更早版本,2k;7.0版,8k)数据库时用到的表页面大小无关 persistformat 可读写long类型,设置或返回由调用save方法所创建的recordset文件的格式。当前仅有一个值adpersistadtg(默认格式:advanced data tablegram) recordcount* 只读long类型,如果recordset支持近似定位或支持书签,则返回带可流动游标的recordset所含有的记录数;如果不支持,必须使用movelast方法以取得确实覆盖了所有记录的准确的recordcount数值。如果forward-only类型recordset有一条或多条记录,recordset返回-1(true),任何类型的空的recordset都将返回0(false) sort* 可读写string类型,包含一条不含保留字order by的sql ordery by子句,用以指定recordset的排序方式 source* 可读写string类型,可以是sql语句、表名、存储过程名或相关command对象名。如果提供了command对象名,则source将返回command.commandtext的值。利用open方法的参数lngoptions可以指定提供给source值的类型 state 可读写long类型,为对象状态常数之一。见state常数 status 只读long类型,表明对recordset进行批处理或其他多记录(bulk)操作后的状态。见status属性用到的常数 注意:上表所列属性是adodb.recordset对象的标准属性,即那些被关系数据库的大多数通用ole db数据提供者所支持的属性。带星号的属性表示它与dao.recordset或rdoresultset对象的相应属性完全一样或很接近。 方法 方法 用途 addnew* 向可更新的recordset添加一条新记录。调用语法为rstname.addnew[{varfield|avarfields},{varvalue|avarvaluese}],其中varfield是单个字段名,avarfields是字段名数组。varvalue是单个字段值,avarvalue是由avarfields指定字段的值所组成的数组。调用update方法则把新记录加到数据库的表中。如果向主关键字不是第一个字段的recordset中添加记录,则必须在addnew方法中指定主关键字的名称和值 cancel 取消异步查询的执行,中止存储过程或复合sql语句创建多个recordset,调用语法为rstname.cancel cancelbatch* 取消lockedit值为batchoptimistic的recordset的即将生效的批量更新操作,调用语法为:rstname.cancelbatch [lngaffectrecords],可选参数lngaffectrecords的取值见lngaffectrecords用到的常数 clone 复制一个带有独立记录指针的recordset对象,调用语法为:set rstdupe=rstname.clone() close 关闭recordset对象,以后可以重新设recordset的属性并使用open方法来再度访问recordset 。调用语法为:rstname.close delete* 如果recordset的lockedit属性值未设为adlockbatchoptimistic,立刻从recordset和相应表中删除当前记录 find 寻找满足指定条件的记录。调用语法为:rstname.find strcriteria [,lngskiprecords, lngsearchdirection [,lngstart]],其中strcriteria是不含where关键字的sql where子句,可选参数lngskiprecords是应用find前所跳过的记录数目,lngdirection指定查找方向(adsearchforward,和adsearchbackward,其中adsearchforward是默认值),可选参数lngstart指定了从哪儿开始查找,其值要么是一个bookmark值,要么是bookmark常数,见varstart参数用到的bookmark常数。 getrows 返回一个二维variant数组(行、列),调用语法为avarname=rstname.getrows(lngrows [,varstart[,{strfieldname|lngfieldindex|avarfieldnames|avarfieldindexes}]],其中lngrows是返回记录行数,varstart指定从哪儿开始查找,其值要么是一个bookmark值,要么是bookmark常数,见varstart参数用到的bookmark常数。第三个参数可以是单个列(字段)的名称或索引,也可以是多个列名称或索引组成的variant数组。如果不指定第三个参数,getrows返回recordset中所有列。 getstring 默认情况下,返回指定数目记录的string串值,记录间由返回代码分隔。记录内由tab分隔。调用语法为: strclip=rstname.getstring(lngrows,[, strcloumndelimiter[,strrowdelimiter,[strnullexpr]]])。其中lngrows为返回记录行数,strcolumndelimiter为可选的列分隔符(vbtab是默认值),strrowdelimiter是可选的行分隔符(vbcr是默认值),strnullexpr是可选参数,用于碰到null值时的替代值(默认值是空字符串)。getstring的主要用途是通过把控件的clip属性设为strclip来处理msflexgrid或mshflexgrid控件 move* 从当前记录移动记录指针。调用语法为:rstname.move lngnumrecords [, varstart],其中lngnumrecords是要跳过的记录数,可选选参数varstart指定从哪开始移动。其值要么是一个bookmark值,要么是bookmark常数,见varstart参数用到的bookmark常数。 movefirst* 移动记录指针到第一条记录,调用语法为:rstname.movefirst movelast* 移动记录指针到最后一条记录,调用语法为:rstname.movelast movenext 移动记录指针到下一条记录,调用语法为:rstname.movenext。它是能用于forward-only recordset的唯一move方法 moveprevious* 移动记录指针到前一条记录,调用语法为:rstname.moveprevious nextrecordset 返回另外的recordset,它通常由能产生多个recordset的复合sql语句(如select * from orders;select * from customers)或存储过程来创建。调用语法为next=rstname.nextrecordset [(lngrecordsaffected)],其中可选参数lngrecordsaffected指定返回到rstnext中去的记录数目。如果已不存在recordset,rstnext被设为nothing open 在一个活动comman</p> <div class="clear-both"></div> </div> <div class="pages"><a href=20050818001835272.htm target="_self" >首页</a> <a href=20050818001835272_2.htm target="_self">下页</a> <a href=20050818001835272_2.htm target="_self">尾页</a> <a href=20050818001835272.htm target="_self"><strong>[1]</strong></a> <a href=20050818001835272_2.htm target="_self">[2]</a> </div> <div class="keywords"> <strong>本文关键:</strong>数据库 </div> <div class="ad_doc_ad_2"> <script type="text/javascript"><!-- google_ad_client = "pub-1022332794981269"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-03-23: 方案站728x90 google_ad_channel = "2351411502"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "3D81EE"; google_color_text = "4C4C4C"; google_color_url = "6C82B5"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <div class="clear-both"></div> </div> </div> <div id="content_right"> <div class="cbox" id="relate_doc"> <div class="darkboxTitle"><span>  相关方案</span></div> <div class="ad_site_index_right_1"> <!-- SiteSearch Google --> <form method="get" action="http://www.google.cn/custom" target="google_window"> <table border="0" bgcolor="#ffffff"> <tr><td nowrap="nowrap" valign="top" align="left" height="32"> <a href="http://www.google.com/"> <img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"></img></a> <br/> <input type="hidden" name="domains" value="www.cn-doc.com"></input> <label for="sbi" style="display: none">输入您的搜索字词</label> <input type="text" name="q" size="15" maxlength="255" value="" id="sbi"></input> <label for="sbb" style="display: none">提交搜索表单</label> <input type="submit" name="sa" value="搜索" id="sbb"></input> </td></tr> <tr> <td nowrap="nowrap"> <table> <tr> <td> <input type="radio" name="sitesearch" value="" id="ss0"></input> <label for="ss0" title="搜索网络"><font size="-1" color="#000000">Web</font></label></td> <td> <input type="radio" name="sitesearch" value="www.cn-doc.com" checked id="ss1"></input> <label for="ss1" title="搜索 www.cn-doc.com"><font size="-1" color="#000000">www.cn-doc.com</font></label></td> </tr> </table> <input type="hidden" name="client" value="pub-1022332794981269"></input> <input type="hidden" name="forid" value="1"></input> <input type="hidden" name="channel" value="9722277709"></input> <input type="hidden" name="ie" value="GB2312"></input> <input type="hidden" name="oe" value="GB2312"></input> <input type="hidden" name="flav" value="0000"></input> <input type="hidden" name="sig" value="Dl1iwOxBnXTtaDIa"></input> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:200;L:http://www.cn-doc.com/images/forgoogle.gif;S:http://www.cn-doc.com;FORID:1"></input> <input type="hidden" name="hl" value="zh-CN"></input> </td></tr></table> </form> <!-- SiteSearch Google --> </div> <ul class="darklist"> <li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001835152.htm" title="关于Visual Basic 6.0类开发(二)" target="_blank">关于Visual Basic </a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/2005081800183521.htm" title="直接访问WebBrowser控件中的HTML源码 (收藏)" target="_blank">直接访问WebBrowser控</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836939.htm" title="表达式编译计算器(下)" target="_blank">表达式编译计算器(下)</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836912.htm" title="在TEXT文本框中只允许输入数字和小数点,如何实现?只能编程实现吗?" target="_blank">在TEXT文本框中只允许输入数</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836271.htm" title="Drawing &amp; Animation III" target="_blank">Drawing &amp; A</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836318.htm" title="用VB编写异步多线程下载程序" target="_blank">用VB编写异步多线程下载程序</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836479.htm" title="VB串口使用心得两则" target="_blank">VB串口使用心得两则</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836616.htm" title="从 RDO到 ADO 的移植" target="_blank">从 RDO到 ADO 的移植</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001836612.htm" title="用VB编写COM+应用时碰到问题?" target="_blank">用VB编写COM+应用时碰到问</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001837602.htm" title="Oracle Objects for OLE 及在VB中的应用" target="_blank">Oracle Objects </a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001835683.htm" title="将你的Visual Basic 6.0移植到Visual Basic.NET" target="_blank">将你的Visual Basic</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001835819.htm" title="表达式编译计算器(上)" target="_blank">表达式编译计算器(上)</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834430.htm" title="基于ADSI的NT帐号及Exchange Server帐号申请及验证模块源代码" target="_blank">基于ADSI的NT帐号及Exc</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834253.htm" title="关于REALPLAYER显示图像的方法" target="_blank">关于REALPLAYER显示图</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834436.htm" title="针对 Microsoft Visual Basic 用户的 ASP+ 和 Web 窗体" target="_blank">针对 Microsoft Vi</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834414.htm" title="用VB6.0设计简易赛车游戏" target="_blank">用VB6.0设计简易赛车游戏</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834365.htm" title="将RichTextBox设置为自动换行或非自动换行" target="_blank">将RichTextBox设置为</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834174.htm" title="将阿拉伯数字转成中文字" target="_blank">将阿拉伯数字转成中文字</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834716.htm" title="常见问题:自动调整窗口内控间的大小" target="_blank">常见问题:自动调整窗口内控间的</a>…</li><li><a href="../../_soft_visual_basic_tech_doc/2005_08_18_00/20050818001834636.htm" title="如何用VB获得机器的MAC地址" target="_blank">如何用VB获得机器的MAC地址</a>…</li> </ul> <div class="ad_site_index_right_2"> <script type="text/javascript"><!-- google_ad_client = "pub-1022332794981269"; google_ad_width = 180; google_ad_height = 60; google_ad_format = "180x60_as_rimg"; google_cpa_choice = "CAAQ0cX8zwEaCEpGRZ0Cl8yyKPu_93M"; google_ad_channel = "6903800490"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </div> <div class="clear-both">&nbsp;</div> <div id="ContentBottom" class="darkBox"> <p>本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)</p><a href="#"><img src="../../images/btn_top.gif" width="51" height="11" alt="go top"/></a> </div> </div> </div> <script type="text/javascript" language="javascript" src="../../comm/doc/w3c_99_bottom.js"></script> <script type="text/javascript" language="javascript" src="../../comm/clicksum_doc.asp?typeid=44&infoid=367001"></script> <script type="text/javascript" language="JavaScript" src="../../comm/statistics.js"></script> </body> </html>