VB and VBA Users Source Code: Obtaining Jet conflict table details
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Obtaining Jet conflict table details
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, April 02, 2001
Hits:
570
Category:
Database/SQL/ADO
Article:
In Microsoft Jet 4.0, all conflicts and errors are logged as conflicts in conflict tables, which are replicated throughout the entire replica set. This is a decentralized conflict model where any user can view a conflict and change the outcome of the conflict by using the Microsoft Replication Conflict Viewer, automatically invoked when a conflict is encountered. If you prefer to automate conflict resolution for your application, you can write a custom function to resolve conflicts, then override the built-in application by using JRO to set the ConflictFunction property to the name of your custom function. When you enhance the Microsoft Jet algorithm with your own VBA function, Microsoft Jet will still initially resolve conflicts by using its own algorithm, but you can use your code to manipulate the results. The ConflictFunction property can be set only in the Design Master, since it is considered a design change to the database. 'Purpose : Returns conflict information on a JET database 'Inputs : sSourceDatabase The path to the source database path eg. C:\nwind.mdb 'Outputs : Returns the number of conflicts or -1 indicates an error occurred 'Author : Andrew Baker 'Date : 15/01/2001 11:55 'Notes : Add reference Microsoft Jet and Replication Objects X.X library, ' where (X.X is greater than or equal to 2.1) 'Revisions : 'Assumptions : Public Function JetGetConflicts(sDatabasePath As String, avConflictData As Variant) As Long Dim Conn As New ADODB.Connection Dim rstConflicts As New ADODB.Recordset Dim repConflicts As New JRO.Replica Dim lNumConflicts As Long, lThisConflict As Long On Error GoTo ErrFailed Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sDatabasePath Set repConflicts.ActiveConnection = Conn Set rstConflicts = repConflicts.ConflictTables lNumConflicts = rstConflicts.RecordCount If lNumConflicts Then 'Database has conflicts, get conflict info. avConflictData = rstConflicts.GetRows Set repConflicts = Nothing JetGetConflicts = lNumConflicts rstConflicts.Close Set rstConflicts = Nothing Conn.Close Set Conn = Nothing Else 'No conflicts on this database JetGetConflicts = 0 avConflictData = Empty End If Exit Function ErrFailed: 'Failed. 'Empty results variable and return error flag avConflictData = Empty JetGetConflicts = -1 End Function 'Demonstration routine Sub Test() Dim asConflicts() As String, lThisConflict As Long, lNumConflicts As Long lNumConflicts = JetGetConflicts("C:\vbusers.mdb", asConflicts) If lNumConflicts > 0 Then MsgBox "The database has conflicts..." Else MsgBox "The database has no conflicts..." End If End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder