590
社区成员
发帖
与我相关
我的任务
分享
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Data.OleDb
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Dim Adapter As New OleDbDataAdapter
Dim Table As New DataTable
Adapter.Fill(Table, Dts.Variables("v_Result").Value) '此时我的ADO变量是v_Result
'得到DataTable,就可以做所有我们想做的事情了.
Dim msg As String
For Each _dataRow As DataRow In Table.Rows
msg = ""
For Each _dataColumn As DataColumn In Table.Columns
msg += _dataColumn.ColumnName + " : " + _dataRow(_dataColumn.Ordinal).ToString + vbTab
Next
'显示msg出来
MsgBox(msg)
Next
Dts.TaskResult = Dts.Results.Success
End Sub
End Class