发 帖  
原厂入驻New

Resync 方法范例 (VB)

2009-1-8 10:24:30  1907
分享
<p><font face="Verdana">Resync 方法范例 (VB)</font></p><font face="Verdana">
<p><br/>本范例演示使用 Resync 方法来刷新静态记录集中的数据。</p>
<p>Public Sub ResyncX()</p>
<p>&nbsp;&nbsp;&nbsp; Dim strCnn As String<br/>&nbsp;&nbsp;&nbsp; Dim rsttitles As ADODB.Recordset</p>
<p>&nbsp;&nbsp;&nbsp; ' Open connections.<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=; "</p>
<p>&nbsp;&nbsp;&nbsp; ' Open recordset for Titles table.<br/>&nbsp;&nbsp;&nbsp; Set rstTitles = New ADODB.Recordset<br/>&nbsp;&nbsp;&nbsp; rstTitles.CursorType = adOpenStatic<br/>&nbsp;&nbsp;&nbsp; rstTitles.LockType = adLockBatchOptimistic<br/>&nbsp;&nbsp;&nbsp; rstTitles.Open "Titles", strCnn, , , adCmdTable</p>
<p>&nbsp;&nbsp;&nbsp; ' Change the type of the first title in the recordset.<br/>&nbsp;&nbsp;&nbsp; rstTitles!Type = "database"</p>
<p>&nbsp;&nbsp;&nbsp; ' display the results of the change.<br/>&nbsp;&nbsp;&nbsp; MsgBox "Before resync: " &amp; vbCr &amp; vbCr &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Title - " &amp; rstTitles!Title &amp; vbCr &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Type - " &amp; rstTitles!Type</p>
<p>&nbsp;&nbsp;&nbsp; ' Resync with database and redisplay results.<br/>&nbsp;&nbsp;&nbsp; rstTitles.Resync<br/>&nbsp;&nbsp;&nbsp; MsgBox "After resync: " &amp; vbCr &amp; vbCr &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Title - " &amp; rstTitles!Title &amp; vbCr &amp; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Type - " &amp; rstTitles!Type</p>
<p>&nbsp;&nbsp;&nbsp; rstTitles.CancelBatch<br/>&nbsp;&nbsp;&nbsp; rstTitles.Close</p>
<p>End Sub</p>
<p></font>&nbsp;</p>
0
2009-1-8 10:24:30   评论 分享淘帖

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

135个成员聚集在这个小组

加入小组

创建小组步骤

关闭

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

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