Convert Activex Scripts to VB / C# Script tast for SQL2008
i converting sql 2005 server 2008. have old active x script need convert script task ssis...
i not familar vb/c# scripting not know how convert use in 2008.
when run receive error " an error occurred while adding managed ssis type library script host. verify dts 2000 runtime installed". believe want avoid invoking legacy functionality converting scripts @ point better.
'********************************************************************** ' visual basic activex script '********************************************************************** function main() dim strto dim strcc dim strsubject dim strbody 'construct subject , body , set attachment path strsubject = "validation #" + cstr(dtsglobalvariables("val_id").value) + " (" + cstr(dtsglobalvariables("errorcount").value) + "): " + dtsglobalvariables("val_name") strbody = "description:<br />" + vbcrlf + replace(dtsglobalvariables("val_dscr").value, "''", "'") + vbcrlf + vbcrlf + "<br /><br />suggestions:<br />" + vbcrlf + replace(dtsglobalvariables("val_web_notes").value, "''", "'") strattachmentpath = dtsglobalvariables("fileattachmentpath").value 'construct address lists depending on if there errors if dtsglobalvariables("errorcount").value = 0 strto = dtsglobalvariables("emailaddynoerrorsto").value strcc = dtsglobalvariables("emailaddynoerrorscc").value else strto = dtsglobalvariables("emailaddyerrorsto").value strcc = dtsglobalvariables("emailaddyerrorscc").value end if 'if there's send email to, so. if len(strto) > 0 call sendsmtpemail(strto, strcc, strsubject, strbody, strattachmentpath) end if main = dtstaskexecresult_success end function '*********************************************************************************************************************************************************** 'this function sends email '*********************************************************************************************************************************************************** function sendsmtpemail(toaddresses, ccaddresses, subjecttext, bodytext, attachmentpath) dim imsg dim iconf dim flds const cdosendusingport = 2 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") = "smtp.mail.com" .item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 .update end with imsg set .configuration = iconf .to = toaddresses .cc = ccaddresses .from = "opsvalidator@somewhere.com" .subject = subjecttext ' .textbody = bodytext .htmlbody = bodytext .addattachment (attachmentpath) .send end set imsg = nothing set iconf = nothing set flds = nothing end function
kdw
it looks not need scripts in ssis 2008.
you can use of of box send email task , define logic within tasks expressions.
SQL Server > SQL Server Integration Services
Comments
Post a Comment