Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
SqlDependency - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, MonoTouch for iPhone, MonoDroid for Android, and Windows Azure.

News

Personal Blog

Work Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

SqlDependency

I just checked the SqlDependency object in .NET Whidbey Beta 2.  As I remember, in Beta 1, you had to iterate through the data that was returned.  In Beta 2, I just tried it and you don't have to iterate through the rows that are returned (unless that is happening behind the scenes and I don't know it).

        Dim strSql As String = "select col1, col2, col3 from owner.tablename"
        Dim sqlDr As SqlDataReader
        sqlCn = New SqlConnection(ConnectionString)
        sqlCm = New SqlCommand(strSql, sqlCn)
        sqlCn.Open()
        sqlDep = New SqlDependency(sqlCm)
        sqlDr = sqlCm.ExecuteReader()
        sqlDr.Close()
        AddHandler sqlDep.OnChange, AddressOf DependencyChangeCallBackFunction

I tested the code above, and my event handler fired when I made my change.  Nice.

Wally

Comments

Manish Gupta said:

HI

I tried using SQL Dependency but it is getting fired again and again without even any event occurs. I am not able to understand why. I used one code which was running perfectly and then i copied it and wrote my own code with my own variable. But it seems that its OnChange event is getting fired again and again

# March 5, 2007 4:17 AM

Basu said:

Even I am facing the same problem that it is getting fired again and again without even any event.

# July 31, 2007 3:49 PM

Vasudevan Rajagopalrao said:

I had this issue. The reason that caused me because I hadn't used dbo.TableName in my query. Check this. Belive me, it resolved it

# August 3, 2007 2:50 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)