Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 332793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:53:59+00:00 2026-05-12T09:53:59+00:00

i would like my windows service (to be written in .NET) to recognize when

  • 0

i would like my windows service (to be written in .NET) to recognize when new rows are added to a specific table, but instead of pulling the data from the sql-server i would like to use a server push model.

does somebody has a hint for me how to achieve this?
i am using sql server 2005.

tia

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:53:59+00:00Added an answer on May 12, 2026 at 9:53 am

    There’s also the ADO.NET SqlDependency mechanism if you’re using client side ADO.NET with C# or VB.NET

    A SqlDependency object can be
    associated with a SqlCommand in order
    to detect when query results differ
    from those originally retrieved. You
    can also assign a delegate to the
    OnChange event, which will fire when
    the results change for an associated
    command. You must associate the
    SqlDependency with the command before
    you execute the command. The
    HasChanges property of the
    SqlDependency can also be used to
    determine if the query results have
    changed since the data was first
    retrieved.

    You basically associate a SqlDependency with your SqlCommand, and provide an event handler that gets called when values that make up the result set of that SqlDependency change.

    using(SqlCommand cmd = new SqlCommand(queryStatement, _conn))
    { 
       cmd.Notification = null;
    
       SqlDependency dependency = new SqlDependency(cmd);
    
       dependency.OnChange += 
           new OnChangeEventHandler(OnChange);
    
        ......
    }
    

    In the event handler, you can then do whathever you need to do.

    void OnChange(object sender, SqlNotificationEventArgs e)
    {
      SqlDependency dependency = sender as SqlDependency;
    
      (do whatever you need to do - e.g. reload the data)
    
    }
    

    Marc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows service written in C# .NET framework 3.5 and would like
In a .Net 3.5 (Windows) service, I would like to store a small collection
I have a Windows Service (written in .NET 1.1) running under a specific user
I would like to block certain URLs dynamically from Windows Service written in C#.
I have written a windows service in C. I would like to install/uninstall it
I have a Windows Service and I would like to see what it's doing
i'd like to create a windows service that would be accessible via WCF from
I'm new to asp.net mvc and web development in general and would like to
I would like to wrap a java program into a windows service with C#
I am starting development of a windows service and would like to consult the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.