VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified

by Connective Solutions LLC. (nofx) (3 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 2nd October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified, but there are many ways to do it without

API Declarations


and what i''m talking
''about.
''PS. Wish you luck with this one and i hope that you''ll find it useful
as i did.

Public rst as ADODB.Recordset
Public db as ADODB.Connection


Rate Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified



been made in
''the database.
''Lets begin...

''1. We gonna have the Command Button that will Connect to the database.

Private Sub cmdConnect_Click()

Set db = New ADODB.Connection
Set rst = New ADODB.Recordset

''Now lets provide the connection for the database.

db.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\hfs200.mdb"

''Now the Query - NOTE: If you want to match for changes on every field in
the
''database all Fields must be open within the Query.

''You use your own tables its only my example here.

rst.Open "SELECT tblManifest.Container, tblManifest.Seal,
tblManifest.Origin FROM tblManifest;", db, adOpenDynamic, adLockOptimistic

''Now lets get all the fields into varRst.

varRst = rst.GetRows
rst.MoveFirst

''Here you can add populating the TreeView with all the database entries.

End Sub

''Now have the Timer Enabled.True set Interval for 30sec so its runs all
the
''time and put this code inside it.

Private Sub Timer1_Timer()
Set db = New ADODB.Connection
Set rst = New ADODB.Recordset

''We''re opening the Database again with the same Query.
db.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\hfs200.mdb"

rst.Open "SELECT tblManifest.Container, tblManifest.Seal,
tblManifest.Origin FROM tblManifest;", db, adOpenDynamic, adLockOptimistic

''now here we gonna use varRst2 to hold the opened query entries.

varRst2 = rst.GetRows
rst.MoveFirst
Call CompareVars ''Here we call Matching Subroutine.

End Sub


''Inside the Module.

Sub CompareVars()
dim x as long
dim y as long
dim cols as long

for x = 0 to UBound(varRst, 2)
  for cols = 0 to Ubound(varRst, 1)
    if varRst(cols, x) <> varRST2(cols, x) then
         ''Here i call TreeView Refresh because we found the change.
          cmdConnect.Value = True ''Clicks the Button to connect.
    end if
  next
next

End Sub

''This is preatty useful piece of code, couldn''t find the other way to
not waste
''the bandwidth for Refreshing the Database every 30 second. So when it
finds
''that the database has been updated it updates the TreeView for me,
otherwise
''it''ll not triger Refresh event.     ENJOY.

Download this snippet    Add to My Saved Code

Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified Comments

No comments have been posted about Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified. Why not be the first to post a comment about Its stupid how Microsoft ADO doesn't have function to tell the user that Database has been modified.

Post your comment

Subject:
Message:
0/1000 characters