Sql server 那么f不是什么都不是(dView) dView.Dispose() dView=无 如果结束 特例 dView=无 结束尝试 端接头 公共共享函数Null2Space(_ ByVal strValue作为对象_ 可选的ByVal-blnDash作为布尔值=
那么f不是什么都不是(dView) dView.Dispose() dView=无 如果结束 特例 dView=无 结束尝试 端接头 公共共享函数Null2Space(_ ByVal strValue作为对象_ 可选的ByVal-blnDash作为布尔值=False_ )作为字符串 尝试 如果为空(标准值),则 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 ElseIf strValue为System.DBNull.Value,则 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 ElseIf strValue.ToString.Trim.Length()<1然后 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 其他的 Null2Space=strValue.ToString.Trim() 如果结束 特例 Null2Space=strValue.ToString 结束尝试 端函数 末级 公共类DBSQLRS 公共共享函数SetDBCon(_ ByRef dbCon作为SqlConnection_ ByRef strError作为字符串_ 可选的ByVal dbName As String=“*******”_ 可选ByVal dbUser As String=“*****”_ )作为布尔值 尝试 如果dbUser=“ELI_Web”,则 dbCon=新的SqlConnection(“*******”) ElseIf dbUser=“ELI_URP”然后 dbCon=新的SqlConnection(“*******”) 如果结束 dbCon.Open() SetDBCon=True 特例 strError=ex.消息 SetDBCon=False 结束尝试 端函数 公共共享函数SetDBCmd(_ ByRef dbCon作为SqlConnection_ ByRef dbCmd作为SqlCommand_ ByVal strCmd作为字符串_ ByRef strError作为字符串_ )作为布尔值 尝试 dbCmd=新的SqlCommand(strCmd、dbCon) dbCmd.CommandType=Data.CommandType.StoredProcess SetDBCmd=True 特例 strError=ex.消息 SetDBCmd=False 结束尝试 端函数 公共共享函数SetDBPar(_ ByRef dbCmd作为SqlCommand_ ByRef dbPar作为SqlParameter_ ByVal strParName作为字符串_ ByVal objParValue作为对象_ ByVal dbType作为Data.SqlDbType_ ByRef strError作为字符串_ )作为布尔值 尝试 dbPar=新的SqlParameter(strParName,dbType) dbPar.IsNullable=True dbPar.Value=objParValue dbCmd.Parameters.Add(dbPar) SetDBPar=True 特例 strError=ex.消息 SetDBPar=False 结束尝试 端函数 公共共享子处置对象(_ 可选ByRef dbCon作为SqlConnection=Nothing_ 可选ByRef dbCmd作为SqlCommand=Nothing_ 可选ByRef dbPar作为SqlParameter=Nothing_ 可选ByRef dbRdr作为SqlDataReader=Nothing_ 可选ByRef dbAda作为SqlDataAdapter=Nothing_ 可选ByRef dbDSet As DataSet=Nothing_ 可选ByRef dTable As DataTable=Nothing_ 可选ByRef dView As DataView=无_ ) 尝试 如果不是空(dbDSet),则 dbDSet.Dispose() dbDSet=Nothing 如果结束 特例 dbDSet=Nothing 结束尝试 尝试 如果不是空(dbAda),则 dbAda.Dispose() dbAda=无 如果结束 特例 dbAda=无 结束尝试 尝试 如果不是空(dbRdr),则 如果不是dbRdr.isclose,则是dbRdr.Close() dbRdr=无 如果结束 特例 dbRdr=无 结束尝试 尝试 如果不是空(dbPar),则 dbPar=无 如果结束 特例 dbPar=无 结束尝试 尝试 如果不是IsNothing(dbCmd),则 dbCmd.Dispose() 如果结束 特例 dbCmd=无 结束尝试 尝试 如果不是空(dbCon),则 如果dbCon.State=ConnectionState.Open,则 dbCon.Close() 如果结束 dbCon.Dispose() 如果结束 特例 dbCon=无 结束尝试 尝试 如果不是Nothing(dTable),则 dTable.Dispose() dTable=无 如果结束 特例 dTable=无 结束尝试 尝试 如果不是什么都不是(dView),那么 dView.Dispose() dView=无 如果结束 特例 dView=无 结束尝试 端接头 公共共享函数Null2Space(_ ByVal strValue作为对象_ 可选的ByVal-blnDash作为布尔值=False_ )作为字符串 尝试 如果为空(标准值),则 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 ElseIf strValue为System.DBNull.Value,则 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 ElseIf strValue.ToString.Trim.Length()<1然后 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 其他的 Null2Space=strValuSql server 那么f不是什么都不是(dView) dView.Dispose() dView=无 如果结束 特例 dView=无 结束尝试 端接头 公共共享函数Null2Space(_ ByVal strValue作为对象_ 可选的ByVal-blnDash作为布尔值=,sql-server,vb.net,ssis,db2,dts,Sql Server,Vb.net,Ssis,Db2,Dts,那么f不是什么都不是(dView) dView.Dispose() dView=无 如果结束 特例 dView=无 结束尝试 端接头 公共共享函数Null2Space(_ ByVal strValue作为对象_ 可选的ByVal-blnDash作为布尔值=False_ )作为字符串 尝试 如果为空(标准值),则 如果班达什那么 Null2Space=“-” 其他的 Null2Space=“” 如果结束 ElseIf strValue为System.DBNull.Value,则 如果班达什那么 N
' 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
Imports System.Data.SqlClient
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
' 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.
Dim db2Con As OleDbConnection = Nothing
Dim strError As String = Nothing
Dim db2Cmd As OleDbCommand = Nothing
Dim db2Rdr As OleDbDataReader = Nothing
Dim EODC_Audit_DataTable As New DataTable
Public Sub Main()
'
' Add your code here
'
Dts.Variables("Audit_Row_Ct").Value = CheckForEODC()
Dts.TaskResult = ScriptResults.Success
End Sub
Public Function CheckForEODC() As Integer
CheckForEODC = 0
Try
If Not DB2RS.SetDBCon(db2Con, strError) Then Throw New Exception(strError)
If Not DB2RS.SetDBCmd(db2Con, db2Cmd, "SELECT * FROM " + Dts.Variables("Region").Value.ToString + ".****", strError) Then Throw New Exception(strError)
db2Rdr = db2Cmd.ExecuteReader
EODC_Audit_DataTable.Load(db2Rdr)
Catch ex As Exception
Dts.VariableDispenser.LockForWrite("stdError")
Dts.Variables("strError").Value = "Load Error: " & ex.Message & "<br /> "
Dts.Variables.Unlock()
Finally
DB2RS.DisposeOfObjects(db2Con, db2Cmd, db2Rdr)
End Try
If (**** < 1) Then
CheckForEODC = 0
Else
CheckForEODC = ****
End If
End Function
End Class
Public Class DB2RS
Public Shared Function SetDBCon( _
ByRef dbCon As OleDbConnection, _
ByRef strError As String _
) As Boolean
Try
dbCon = New OleDbConnection(Dts.Variables("DB2ConnectionString").Value.ToString)
dbCon.Open()
SetDBCon = True
Catch ex As Exception
strError = ex.Message
SetDBCon = False
End Try
End Function
Public Shared Function SetDBCmd( _
ByRef dbCon As OleDbConnection, _
ByRef dbCmd As OleDbCommand, _
ByVal strCmd As String, _
ByRef strError As String _
) As Boolean
Try
dbCmd = New OleDbCommand(strCmd, dbCon)
dbCmd.CommandType = Data.CommandType.Text
SetDBCmd = True
Catch ex As Exception
strError = ex.Message
SetDBCmd = False
End Try
End Function
Public Shared Sub DisposeOfObjects( _
Optional ByRef dbCon As OleDbConnection = Nothing, _
Optional ByRef dbCmd As OleDbCommand = Nothing, _
Optional ByRef dbRdr As OleDbDataReader = Nothing, _
Optional ByRef dbAda As OleDbDataAdapter = Nothing, _
Optional ByRef dbDSet As DataSet = Nothing, _
Optional ByRef dTable As DataTable = Nothing, _
Optional ByRef dView As DataView = Nothing _
)
Try
If Not IsNothing(dbDSet) Then
dbDSet.Dispose()
dbDSet = Nothing
End If
Catch ex As Exception
dbDSet = Nothing
End Try
Try
If Not IsNothing(dbAda) Then
dbAda.Dispose()
dbAda = Nothing
End If
Catch ex As Exception
dbAda = Nothing
End Try
Try
If Not IsNothing(dbRdr) Then
If Not dbRdr.IsClosed Then dbRdr.Close()
dbRdr = Nothing
End If
Catch ex As Exception
dbRdr = Nothing
End Try
Try
If Not IsNothing(dbCmd) Then
dbCmd.Dispose()
End If
Catch ex As Exception
dbCmd = Nothing
End Try
Try
If Not IsNothing(dbCon) Then
If dbCon.State = ConnectionState.Open Then
dbCon.Close()
End If
dbCon.Dispose()
End If
Catch ex As Exception
dbCon = Nothing
End Try
Try
If Not IsNothing(dTable) Then
dTable.Dispose()
dTable = Nothing
End If
Catch ex As Exception
dTable = Nothing
End Try
Try
If Not IsNothing(dView) Then
dView.Dispose()
dView = Nothing
End If
Catch ex As Exception
dView = Nothing
End Try
End Sub
Public Shared Function Null2Space( _
ByVal strValue As Object, _
Optional ByVal blnDash As Boolean = False _
) As String
Try
If IsNothing(strValue) Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
ElseIf strValue Is System.DBNull.Value Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
ElseIf strValue.ToString.Trim.Length() < 1 Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
Else
Null2Space = strValue.ToString.Trim()
End If
Catch ex As Exception
Null2Space = strValue.ToString
End Try
End Function
End Class
Public Class DBSQLRS
Public Shared Function SetDBCon( _
ByRef dbCon As SqlConnection, _
ByRef strError As String, _
Optional ByVal dbName As String = "*****", _
Optional ByVal dbUser As String = "*****" _
) As Boolean
Try
If dbUser = "ELI_Web" Then
dbCon = New SqlConnection("*****")
ElseIf dbUser = "ELI_URP" Then
dbCon = New SqlConnection("*****")
End If
dbCon.Open()
SetDBCon = True
Catch ex As Exception
strError = ex.Message
SetDBCon = False
End Try
End Function
Public Shared Function SetDBCmd( _
ByRef dbCon As SqlConnection, _
ByRef dbCmd As SqlCommand, _
ByVal strCmd As String, _
ByRef strError As String _
) As Boolean
Try
dbCmd = New SqlCommand(strCmd, dbCon)
dbCmd.CommandType = Data.CommandType.StoredProcedure
SetDBCmd = True
Catch ex As Exception
strError = ex.Message
SetDBCmd = False
End Try
End Function
Public Shared Function SetDBPar( _
ByRef dbCmd As SqlCommand, _
ByRef dbPar As SqlParameter, _
ByVal strParName As String, _
ByVal objParValue As Object, _
ByVal dbType As Data.SqlDbType, _
ByRef strError As String _
) As Boolean
Try
dbPar = New SqlParameter(strParName, dbType)
dbPar.IsNullable = True
dbPar.Value = objParValue
dbCmd.Parameters.Add(dbPar)
SetDBPar = True
Catch ex As Exception
strError = ex.Message
SetDBPar = False
End Try
End Function
Public Shared Sub DisposeOfObjects( _
Optional ByRef dbCon As SqlConnection = Nothing, _
Optional ByRef dbCmd As SqlCommand = Nothing, _
Optional ByRef dbPar As SqlParameter = Nothing, _
Optional ByRef dbRdr As SqlDataReader = Nothing, _
Optional ByRef dbAda As SqlDataAdapter = Nothing, _
Optional ByRef dbDSet As DataSet = Nothing, _
Optional ByRef dTable As DataTable = Nothing, _
Optional ByRef dView As DataView = Nothing _
)
Try
If Not IsNothing(dbDSet) Then
dbDSet.Dispose()
dbDSet = Nothing
End If
Catch ex As Exception
dbDSet = Nothing
End Try
Try
If Not IsNothing(dbAda) Then
dbAda.Dispose()
dbAda = Nothing
End If
Catch ex As Exception
dbAda = Nothing
End Try
Try
If Not IsNothing(dbRdr) Then
If Not dbRdr.IsClosed Then dbRdr.Close()
dbRdr = Nothing
End If
Catch ex As Exception
dbRdr = Nothing
End Try
Try
If Not IsNothing(dbPar) Then
dbPar = Nothing
End If
Catch ex As Exception
dbPar = Nothing
End Try
Try
If Not IsNothing(dbCmd) Then
dbCmd.Dispose()
End If
Catch ex As Exception
dbCmd = Nothing
End Try
Try
If Not IsNothing(dbCon) Then
If dbCon.State = ConnectionState.Open Then
dbCon.Close()
End If
dbCon.Dispose()
End If
Catch ex As Exception
dbCon = Nothing
End Try
Try
If Not IsNothing(dTable) Then
dTable.Dispose()
dTable = Nothing
End If
Catch ex As Exception
dTable = Nothing
End Try
Try
If Not IsNothing(dView) Then
dView.Dispose()
dView = Nothing
End If
Catch ex As Exception
dView = Nothing
End Try
End Sub
Public Shared Function Null2Space( _
ByVal strValue As Object, _
Optional ByVal blnDash As Boolean = False _
) As String
Try
If IsNothing(strValue) Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
ElseIf strValue Is System.DBNull.Value Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
ElseIf strValue.ToString.Trim.Length() < 1 Then
If blnDash Then
Null2Space = " - "
Else
Null2Space = " "
End If
Else
Null2Space = strValue.ToString.Trim()
End If
Catch ex As Exception
Null2Space = strValue.ToString
End Try
End Function
End Class
If Not DB2RS.SetDBCon(db2Con, strError) Then Throw New Exception(strError)
If Not DB2RS.SetDBCon(db2Con, Dts, strError) Then Throw New Exception(strError)
Public Class DB2RS
Public Shared Function SetDBCon( _
ByRef dbCon As OleDbConnection, _
ByRef Dts As Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel, _
ByRef strError As String _
) As Boolean