在SSIS 2008中将VB脚本转换为C#用于脚本任务 [英] Converting VB Script to C# for Script Task in SSIS 2008
本文介绍了在SSIS 2008中将VB脚本转换为C#用于脚本任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下VB代码,我想转换为C#。我在网站上尝试了许多用于转换但仍然出错。
基本上这个代码在ACTIVE X工具中我想用SCRIPT TASK替换所以需要转换为c# 。
请急需帮助。
Hi,
I have the below VB code and i wanted to convert for C#. I tried many in website for the conversion but still getting errors.
Basically this code in ACTIVE X tool and i wanted to replace with SCRIPT TASK so need to convert to c#.
Please am in need of Help.
Function Main()
Dim sFrom
Dim sTo
Dim sCc
Dim sSubject
Dim sTextBody
Dim sAttach
Dim objMail
Dim iMsg
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
'MsgBox DTSGlobalVariables("Connection_EHSDW").Value
Set cn = CreateObject("ADODB.Connection")
cn.Open DTSGlobalVariables("Connection_EHSDW").Value
Set rs = cn.Execute("SELECT mail_from, mail_to, mail_cc, mail_subject, textbody, attachment_path FROM t_wims_mailing_list WHERE module = 'Claims' and task = 'Daily Claims Summary'" )
If Not rs.EOF Then
sTo = rs("mail_to")
sCc = rs("mail_cc")
sFrom = rs("mail_from")
sSubject = rs("mail_subject")
sTextBody = rs("textbody")
sAttach = rs("attachment_path")
End If
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = _
cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mailserv.mmm.com"
.Update
End With
iMsg.configuration = iConf
iMsg.To = sTo
iMsg.From = sFrom
iMsg.Subject = sSubject
iMsg.TextBody = sTextBody
iMsg.AddAttachment sAttach
iMsg.Send
Set objMail = Nothing
Set oRS = Nothing
Main = DTSTaskExecResult_Success
End Function
推荐答案
在这里:
点击我! [ ^ ]
这篇关于在SSIS 2008中将VB脚本转换为C#用于脚本任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文