Article ID: 202097
Article Last Modified on 10/11/2006
DBEngine(0).BeginTrans ' Update operation here. DBEngine(0).CommitTrans dbForceOSFlushMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The example provided below uses a Visual Basic 5.0 out of process ActiveX server to provide the second instance of Jet while at the same time being able to be precisely synchronized.
Option Explicit
Dim db As Database, rs As Recordset
Private Sub Class_Initialize()
Set db = DBEngine(0).OpenDatabase("nwind.mdb")
Set rs = db.OpenRecordset("Customers")
End Sub
Private Sub Class_Terminate()
rs.Close
db.Close
End Sub
Public Sub UpdateTitle(ByVal NewTitle As String)
DBEngine(0).BeginTrans
rs.Edit
rs!ContactTitle = NewTitle
rs.Update
DBEngine(0).CommitTrans dbForceOSFlush
End Sub
Option Explicit
Dim ws As Workspace, db As Database, obj As Project1.Class1
Private Sub Command1_Click()
Dim rs As Recordset, Temp As String
Dim fDone As Boolean, Counter As Long
If Me!Command1.Caption = "Operator" Then
Temp = "Programmer"
Else
Temp = "Operator"
End If
obj.UpdateTitle Temp
fDone = False
Counter = 0
Do
Counter = Counter + 1
' DBEngine.Idle dbRefreshCache
Set rs = db.OpenRecordset("Customers")
If rs!ContactTitle = Temp Then fDone = True
rs.Close
Loop Until fDone
Me!Command1.Caption = Temp
MsgBox "Took " & Counter & " retries to get the updated data."
End Sub
Private Sub Form_Load()
Set ws = DBEngine.CreateWorkspace("", "Admin", "")
' Set ws = DBEngine.CreateWorkspace("JetTest", "Admin", "")
' DBEngine.Workspaces.Append ws
Set db = ws.OpenDatabase("nwind")
Set obj = New Project1.Class1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set obj = Nothing
db.Close
ws.Close
End Sub
Additional query words: kbDSupport kbdse dbengine idle
Keywords: kbprb kbprogramming KB202097