扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:朱先忠编译 来源:天极开发 2007年10月22日
关键字: SQL Server
在本页阅读全文(共3页)
Imports System.Data.SqlClient Public Class NotificationTest Public Function DepTest() As SqlDataReader Dim conn As New SqlConnection(connstring) conn.Open() Dim cmd As New SqlCommand( "SELECT * FROM authors(", conn)") Dim rdr As SqlDataReader rdr = cmd.ExecuteReader() Return rdr End Function End Class |
Imports System.Data.SqlClient Public Class NotificationTest Dim dep As SqlDependency Public Function DepTest() As SqlDataReader Dim conn As New SqlConnection(connstring) conn.Open() Dim cmd As New SqlCommand( _ "SELECT au_id, au_lname,au_fname " & _ "FROM dbo.authors", conn) dep = New SqlDependency(cmd) Dim rdr As SqlDataReader rdr = cmd.ExecuteReader() Return rdr End Function End Class |
Imports System.Data.SqlClient Public Class NotificationTest Dim dep As SqlDependency Public Function DepTest() As SqlDataReader Dim conn As New SqlConnection(connstring) conn.Open() Dim cmd As New SqlCommand( _ "SELECT au_id,au_lname,au_fname FROM " + _ "dbo.authors", conn) dep = New SqlDependency(cmd) AddHandler dep.OnChange, AddressOf OnDepChange Dim rdr As SqlDataReader rdr = cmd.ExecuteReader() Return rdr End Function '处理器方法 Public Sub OnDepChange(ByVal sender As Object, _ ByVal e As SqlNotificationEventArgs) Dim DepInfo As String = e.Info.ToString '做一些事情以响应通知 End Sub Public ReadOnly Property HasChanges() As Boolean Get Return dep.HasChanges End Get End Property End Class |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者