Calling SSIS package from VB.NET with events -


it's question , answer. trying figure out how open ssis package within vb.net , expose events package check on progress. not find answers online this. turns out, it's quite simple.

here windows form code:

private sub loadssispackage(byval packagefile string)

    if file.exists(packagefile) andalso packagefile.endswith(".dtsx")         dim pkg new microsoft.sqlserver.dts.runtime.package         dim app new microsoft.sqlserver.dts.runtime.application         dim pkgresults microsoft.sqlserver.dts.runtime.dtsexecresult           pkg = app.loadpackage(packagefile, nothing)          dim pkgevents new packageevents           pkgresults = pkg.execute(nothing, nothing, pkgevents, nothing, nothing)         msgbox(pkgresults.tostring())     else         environment.exit(-1)     end if end sub 

here class created:

public class packageevents implements microsoft.sqlserver.dts.runtime.idtsevents

public sub onbreakpointhit(breakpointsite microsoft.sqlserver.dts.runtime.idtsbreakpointsite, breakpointtarget microsoft.sqlserver.dts.runtime.breakpointtarget) implements microsoft.sqlserver.dts.runtime.idtsevents.onbreakpointhit  end sub  public sub oncustomevent(taskhost microsoft.sqlserver.dts.runtime.taskhost, eventname string, eventtext string, byref arguments() object, subcomponent string, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.oncustomevent  end sub  public function onerror(source microsoft.sqlserver.dts.runtime.dtsobject, errorcode integer, subcomponent string, description string, helpfile string, helpcontext integer, idofinterfacewitherror string) boolean implements microsoft.sqlserver.dts.runtime.idtsevents.onerror  end function  public sub onexecutionstatuschanged(exec microsoft.sqlserver.dts.runtime.executable, newstatus microsoft.sqlserver.dts.runtime.dtsexecstatus, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onexecutionstatuschanged  end sub  public sub oninformation(source microsoft.sqlserver.dts.runtime.dtsobject, informationcode integer, subcomponent string, description string, helpfile string, helpcontext integer, idofinterfacewitherror string, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.oninformation     debug.print(cstr(informationcode))     debug.print(cstr(subcomponent))     debug.print(cstr(description))     debug.print(cstr(helpfile))     debug.print(cstr(helpcontext))   end sub  public sub onpostexecute(exec microsoft.sqlserver.dts.runtime.executable, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onpostexecute  end sub  public sub onpostvalidate(exec microsoft.sqlserver.dts.runtime.executable, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onpostvalidate  end sub  public sub onpreexecute(exec microsoft.sqlserver.dts.runtime.executable, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onpreexecute  end sub  public sub onprevalidate(exec microsoft.sqlserver.dts.runtime.executable, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onprevalidate  end sub  public sub onprogress(taskhost microsoft.sqlserver.dts.runtime.taskhost, progressdescription string, percentcomplete integer, progresscountlow integer, progresscounthigh integer, subcomponent string, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onprogress       'debug.print(progressdescription)     'debug.print(cstr(taskhost.executionstatus))     'debug.print(cstr(percentcomplete))     'debug.print(cstr(progresscountlow))     'debug.print(cstr(progresscounthigh))  end sub  public function onquerycancel() boolean implements microsoft.sqlserver.dts.runtime.idtsevents.onquerycancel  end function  public sub ontaskfailed(taskhost microsoft.sqlserver.dts.runtime.taskhost) implements microsoft.sqlserver.dts.runtime.idtsevents.ontaskfailed  end sub  public sub onvariablevaluechanged(dtscontainer microsoft.sqlserver.dts.runtime.dtscontainer, variable microsoft.sqlserver.dts.runtime.variable, byref fireagain boolean) implements microsoft.sqlserver.dts.runtime.idtsevents.onvariablevaluechanged  end sub  public sub onwarning(source microsoft.sqlserver.dts.runtime.dtsobject, warningcode integer, subcomponent string, description string, helpfile string, helpcontext integer, idofinterfacewitherror string) implements microsoft.sqlserver.dts.runtime.idtsevents.onwarning  end sub 

end class

note sub's appear automatically once implements line coded. ssis package events can trapped!

there work regarding cross marshalling on separate threads ssis event info form, that's story...


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -