Hi masters, how to monitor sqlite database in service?
'Code module 'Subs in this code module will be accessible from all modules. Sub Process_Globals Dim dbSQL As SQL Dim dbCursor As Cursor End Sub Sub InitdbSQL 'Change to Correct path of your database dbSQL.Initialize(File.DirDefaultExternal, "yourDB.db", True) End Sub
Sub Service_Create 'You can add this also in activities If DbConnect.dbSQL.IsInitialized = False Then DbConnect.InitdbSQL End If End Sub 'Call your sql from anywhere DbConnect.dbSQL.ExecQuery("SELECT * From YourDb")
That's easy to do. Use triggers in your SQLite tables to generate a log table. Then just query the log table to see what has changed. A simple tutorial on triggers can be found here.Tnx for your reply but. I want to monitor the changes in my database and display a log for that in service. Is it possible?
Sub Service_Create If Main.SQL1.IsInitialized Then Main.SQL1.Close If SQL2.IsInitialized=False Then SQL2.Initialize(DBFileDir, DBFileName, False) End If End Sub ... Cursor=SQL2.ExecQuery("SELECT * FROM Table;")
I understand the important thing (maybe I am wrong) - Service module shall be strict and as effective as possible, although you say it is more simple than activity.Rules - If the target module is already running then the sub will be called.
- If the target module is a service and it is not already running then it will first be started (Service_Create and Service_Start will first be executed).
The sub will be called after Service_Start.