﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » SQL Server Event Handler</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 22:44:46 GMT</lastBuildDate><ttl>20</ttl><item><title>SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24592.aspx</link><description>I need to be able to detect when a row is written to a SQL Server table.  Is it possible to create an event handler or something like that, so I can execute some VB.NET code whenever a record is written.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Tim</description><pubDate>Thu, 10 Sep 2009 05:04:04 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24597.aspx</link><description>You will want to use SQL Server Notification Services.&amp;nbsp; That is the purpose and intent of SQL Server Notification Services (kindof) to notify you once a notification is registered.&amp;nbsp; For example, if you execute a query on the SQL Server you can have SQL Server notify you when anything within that query has changed.&amp;nbsp; It works pretty well if you get all of the SQL Server/Windows permissions setup correctly, but this can be a bit cumbersome as well.&lt;/P&gt;&lt;P&gt;There are several other ways to do this as well.&amp;nbsp; SQL Server Notification Services can be messy and difficult to work with.&amp;nbsp; Generally what I will do is create a checksum query that I call on a thread that checks to see if there are any changes to any records.&amp;nbsp; If you are looking for INSERTs only then it is very simple as you can just get a SUM() of all of the PKs (if they are numeric) or create an aggregate equivalent to tell you otherwise if there are any new records.&amp;nbsp; For any modifications, if you have a row version field, then you can use a SUM() of the row version to determine if there are any changes.&lt;/P&gt;&lt;P&gt;If you can take this approach you will be more in control and move more quickly.&amp;nbsp; But these are just a couple of ideas.&amp;nbsp; Hope they help. :)</description><pubDate>Thu, 10 Sep 2009 05:04:04 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24596.aspx</link><description>that sounds......unpleasant.</description><pubDate>Wed, 09 Sep 2009 22:48:35 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24595.aspx</link><description>I should have provided some further details.&lt;br&gt;
&lt;br&gt;
We are doing some integration to a third party SQL Server database and would like to know if I can detect when a record is written to a specific table. We don't have control on what/when data gets written and I can't touch the database in anyway.  &lt;br&gt;
&lt;br&gt;
I could write a SF windows service to periodically check the table for a record count, on a timer or something like that, however the data is written sporadically throughout the day and I was concerned about having a service continually check for a record.  I was just looking for a better way.&lt;br&gt;</description><pubDate>Wed, 09 Sep 2009 17:56:49 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24594.aspx</link><description>That is on the database side, if you are wanting to do this strictly within Strataframe at the application level, I think there is an AfterAddNew event (or something real close, I dont have SF loaded where I am right now)</description><pubDate>Wed, 09 Sep 2009 17:43:36 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: SQL Server Event Handler</title><link>http://forum.strataframe.net/FindPost24593.aspx</link><description>What you want is a trigger, these are defined at the database level. You can set them up for inserts, updates, deletes etc.</description><pubDate>Wed, 09 Sep 2009 17:41:01 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item></channel></rss>