Calling c# code when a table is modified

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
d.a.hill85
Posts: 2
Joined: Thu 09 Sep 2010 15:28

Calling c# code when a table is modified

Post by d.a.hill85 » Thu 09 Sep 2010 15:49

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

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 10 Sep 2010 16:55

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.

d.a.hill85
Posts: 2
Joined: Thu 09 Sep 2010 15:28

Post by d.a.hill85 » Mon 13 Sep 2010 06:57

Thanks StanislavK, I will look at this today and let you know how it goes.

Dan

Post Reply