ti_showinserted.vb

来自「SQL2005开发指南」· VB 代码 · 共 27 行

VB
27
字号
Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server
Imports System.Data.SqlClient


Partial Public Class Triggers
    ' Enter existing table or view for the target and uncomment the attribute line
    <Microsoft.SqlServer.Server.SqlTrigger(Name:="ti_ShowInserted", Target:="Person.ContactType", Event:="FOR INSERT")> _
    Public Shared Sub ti_ShowInserted()
        Dim oTriggerContext As SqlTriggerContext = _
          SqlContext.TriggerContext
        Dim sPipe As SqlPipe = SqlContext.Pipe
        If oTriggerContext.TriggerAction = TriggerAction.Insert Then

            Dim conn As New SqlConnection("context connection=true")
            conn.Open()
            Dim cmd As New SqlCommand("Select * from inserted", conn)

            sPipe.ExecuteAndSend(cmd)

        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?