RefreshCache Method (JRO)

Access Developer Reference

Forces any pending writes to .mdb files, and refreshes memory with the most current data from the .mdb file.

Syntax

  
    JetEngine
    .RefreshCache(
    Connection
    )
  

Parameters

Connection   The ADO Connection object for which to refresh the cache. An error will occur if the connection is not a valid, open ADO Connection. An error will occur if the provider used to create the connection does not support the RefreshCache method.

Remarks

You don't need to use this method in single-user environments unless multiple connections are made to the database. The RefreshCache method may increase performance in a multiuser environment because it forces the database engine to write data to disk, releasing locks on memory.

Example

This example demonstrates the RefreshCache method.

  Public Sub RefCache()

Dim lateje As JRO.JetEngine Dim conn As New ADODB.Connection Dim conn2 As New ADODB.Connection Dim rs As ADODB.Recordset Dim fld As ADODB.Field

' Open both connections to the database. conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data source=C:\Program Files\Microsoft Office" & _ "Office\Samples\Northwind.mdb;" conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data source=C:\Program Files\Microsoft Office" & _ "Office\Samples\Northwind.mdb;"

Set lateje = CreateObject("JRO.JetEngine")

On Error Resume Next conn.Execute "drop table tab1" On Error GoTo 0

' Create table and input new values for columns. conn.Execute "create table tab1 ( col1 int)" conn.Execute "insert into tab1 values (1)" conn.Execute "insert into tab1 values (2)"

' Flush the data so that conn2 can see the changes from conn1. lateje.RefreshCache conn2 Set rs = conn2.Execute("select * from tab1") Set fld = rs.Fields(0) Debug.Print "Record 1: " & fld.Name & " = " & Str(fld.Value)

conn.Close conn2.Close Set lateje = Nothing

End Sub