Resync Method Example

This example demonstrates using the Resync method to refresh data in a static recordset.

Public Sub ResyncX()

	Dim strCnn As String
	Dim rstTitles As ADODB.Recordset

	' Open connections.
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"

	' Open recordset for titles table.
	Set rstTitles = New ADODB.Recordset
	rstTitles.CursorType = adOpenStatic
	rstTitles.LockType = adLockOptimistic
	rstTitles.Open "titles", strCnn
	
	With rstTitles
	
		' Change the type of the first title in the recordset.
		!Type = "database"
		
		' Display the results of the change.
		MsgBox "Before resync: " & vbCr & vbCr & _
			"Title - " & !Title & vbCr & _
			"Type - " & !Type
		
		' Resync with database and redisplay results.
		.Resync
		MsgBox "After resync: " & vbCr & vbCr & _
			"Title - " & !Title & vbCr & _
			"Type - " & !Type
		
	End With

	rstTitles.Close
	
End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.