发 帖  
原厂入驻New

NextRecordset 方法范例 (VB)

2009-1-8 10:22:47  1960
分享
<p><font face="Verdana">NextRecordset 方法范例 (VB)</font></p><font face="Verdana">
<p><br/>本范例使用 NextRecordset 方法,查看使用复合命令语句的记录集中的数据,其中的复合命令语句由三个独立 SELECT 语句组成。</p>
<p>Public Sub NextRecordsetX()</p>
<p>&nbsp;&nbsp;&nbsp; Dim rstCompound As ADODB.Recordset<br/>&nbsp;&nbsp;&nbsp; Dim strCnn As String<br/>&nbsp;&nbsp;&nbsp; Dim intCount As Integer</p>
<p>&nbsp;&nbsp;&nbsp; ' Open compound recordset.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strCnn = "Provider=sqloLEDb;" &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set rstCompound = New ADODB.Recordset<br/>&nbsp;&nbsp;&nbsp; rstCompound.Open "SELECT * FROM Authors; " &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "SELECT * FROM stores; " &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "SELECT * FROM jobs", strCnn, , , adCmdText</p>
<p>&nbsp;&nbsp;&nbsp; ' display results from each SELECT statement.<br/>&nbsp;&nbsp;&nbsp; intCount = 1<br/>&nbsp;&nbsp;&nbsp; Do Until rstCompound.State = adStateClosed<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; debug.Print "Contents of recordset #" &amp; intCount<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While Not rstCompound.EOF<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.Print , rstCompound.Fields(0), _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rstCompound.Fields(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rstCompound.MoveNext<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set rstCompound = rstCompound.NextRecordset<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intCount = intCount + 1<br/>&nbsp;&nbsp;&nbsp; Loop<br/>&nbsp;&nbsp;&nbsp; <br/>End Sub</p>
<p></font>&nbsp;</p>
0
2009-1-8 10:22:47   评论 分享淘帖

只有小组成员才能发言,加入小组>>

135个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /7 下一条

快速回复 返回顶部 返回列表