Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

ADO Recordset Object Resync Method

Refreshes the data in the current Recordset object from the underlying database.

Resync Method Syntax

recordset.Resync AffectRecords

Resync Method Parameters

AffectRecords

An optional AffectEnum constant that determines how many records the Resync method will affect. Can be one of the following constants:

Constant

Description

adAffectCurrent

Refresh only the current record.

adAffectGroup

Refresh the records that satisfy the current Filter property setting. You must set the Filter property to one of the valid predefined constants in order to use this option. The Filter property is not currently supported on UNIX.

adAffectAll

Default. Refresh all the records in the Recordset object, including any hidden by the current Filter property setting.

Resync Method Remarks

Use the Resync method to re-synchronize records in the current recordset with the underlying database. This is useful if you are using either a static or forward-only cursor but you want to see any changes in the underlying database. Calling the Resync method cancels any pending batch updates.

Unlike the ADO Recordset Object Requery Method, the Resync method does not re-execute the Recordset object's underlying command; new records in the underlying database will not be visible.

If the attempt to resynchronize fails because of a conflict with the underlying data (for example, a record has been deleted by another user), the provider returns warnings to the ADO Errors Collection, but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records. Use the ADO Recordset Object Filter Property (adFilterAffectedRecords) and the ADO Recordset Object Status Property to locate records with conflicts.

Resync Method Examples

This Visual Basic 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 = adLockBatchOptimistic

rstTitles.Open "titles", strCnn, , , adCmdTable

' Change the type of the first title in the recordset.

rstTitles!Type = "database"

' Display the results of the change.

MsgBox "Before resync: " & vbCr & vbCr & _

"Title - " & rstTitles!Title & vbCr & _

"Type - " & rstTitles!Type

' Resync with database and redisplay results.

rstTitles.Resync

MsgBox "After resync: " & vbCr & vbCr & _

"Title - " & rstTitles!Title & vbCr & _

"Type - " & rstTitles!Type

rstTitles.CancelBatch

rstTitles.Close

End Sub

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.