Hi,
I am a complete newbie to both c# and sqlite and was hoping someone would be able to help me out.
My application needs to do something specific when a new row is added to a particular table in a sqlite database (a third party application adds things into the table, and they won't notify me when they do).
Now in my initial, very dirty, attempt I have my application polling that table every 30s and if there is something new (asserted by checking if a "timestamp" column has a datetime within the last 30s) it then reads the data and acts accordingly.
What I ideally want is to have a method in my Data Access Layer called if any data is added to the table. When a row is added to the table I want it to call my DAL method and give it the row Id.
Is that possible, and if so could someone give me a few hints about how to do it?
FYI: my application is c# .net 4.0
Thanks in advance,
Dan
Calling c# code when a table is modified
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
You can perform this in the following way:
1. Create and register a user-defined function defined in your application. Please see the following topic of our documentation for detailed information on this:
http://www.devart.com/dotconnect/sqlite/docs/UDF.html
2. Create a trigger calling this user-defined function whenever a row is inserted into your table. For information on SQLite triggers, please refer to
http://www.sqlite.org/lang_createtrigger.html
I will send you a sample project illustrating this approach. Please check that the letter is not blocked by your mail filter.
Feel free to contact us if anything is unclear.
1. Create and register a user-defined function defined in your application. Please see the following topic of our documentation for detailed information on this:
http://www.devart.com/dotconnect/sqlite/docs/UDF.html
2. Create a trigger calling this user-defined function whenever a row is inserted into your table. For information on SQLite triggers, please refer to
http://www.sqlite.org/lang_createtrigger.html
I will send you a sample project illustrating this approach. Please check that the letter is not blocked by your mail filter.
Feel free to contact us if anything is unclear.
-
- Posts: 2
- Joined: Thu 09 Sep 2010 15:28