Solved

Notification from SQL Server to my App

Posted on 2013-01-14
6
168 Views
Last Modified: 2013-01-18
Hello,

I've been using timers to check some object status from a database (SQL Server 2008 Express). It was all ok, until the data retrieved was big enought that the timers routine to check got inefficient.

I read something about SQLDependency, which triggers an event when a table is changed and notifies my app. That seems to be great, since i have to treat the data only when I really have to...

The problem is I'm kind of a rookie in database structuring and the examples I found were rather complex for me...

Could someone post here a very simple example that i can understand how to use this? Or if there is a better way that would be welcome too.

Thanks in advance.
0
Comment
Question by:toddinho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 38776521
There are some examples alreadyon Internet:

http://msdn.microsoft.com/en-us/library/t9x04ed2(v=vs.80).aspx
and related
http://msdn.microsoft.com/en-us/library/9dz445ks(v=vs.80).aspx

The code is pretty simple.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 38776625
0
 

Author Comment

by:toddinho
ID: 38793735
Wow, thats GREAT!!! Thanks for the example emoreau!!

PS: Sorry for the time i took to accept the solution, I couldn't download the .zip from the office, i had to take it home and email it to myself.
0
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 

Author Comment

by:toddinho
ID: 38793738
Just one last question: If i want to drop a database that has these services it says it's in use. How can i delete them so I can drop it?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38793749
I never tried. but you should be able to use SP_Kill to kill any session (use SP_who2 to find out the sessions).
0
 

Author Comment

by:toddinho
ID: 38794016
I figured this out... It wasn't the Service Broker that was using the database, i had to set it offline.

alter database [DemoNotifications2]
set OFFLINE
with rollback immediate
go
drop database [DemoNotifications2]
go

Thanks anyway :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.NET: How to pass typed serialize using JavaScriptSerializer ==> Deserialize in C# 6 36
Coding for the first time 9 68
C# XML Get Values 4 35
Database Owner 3 20
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question