How to get full error description to display using IDTSEvents.OnError Method when executing package from local ASP.NET web site
I'm able to execute the desired SSIS package by clicking a button on my local asp.net web site using the below code. However, the only information I'm able to display in Label2 is "Success" or "Failure".
If the package fails, I want to see the full error description. Does anyone have suggestions on how to modify the below code to be able to see the full error description in Label2 rather than just the word "Failure"? FYI - I used the console
example on this page http://technet.microsoft.com/en-us/library/ms136090.aspx#prereq as a template.
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult
Dim eventListener As New EventListener()
pkgLocation = _
"C:\Users\test\Desktop\aaaaaaa\Accounting Integration Files\SSIS\Packages\" & _
"Actg Integration\" + Label1.Text
app.PackagePassword = "pwd"
pkg = app.LoadPackage(pkgLocation, eventListener)
pkgResults = pkg.Execute(Nothing, Nothing, eventListener, Nothing, Nothing)
Label2.Text = pkgResults.ToString()
End Sub
End Class
Class EventListener
Inherits DefaultEvents
Public Overrides Function OnError(ByVal source As Microsoft.SqlServer.Dts.Runtime.DtsObject, _
ByVal errorCode As Integer, ByVal subComponent As String, ByVal description As String, _
ByVal helpFile As String, ByVal helpContext As Integer, _
ByVal idofInterfaceWithError As String) As Boolean
' Add applicationspecific diagnostics here.
WriteLine("Error in {0}/{1} : {2}", source, subComponent, description)
Return False
End Function
End Class
May 12th, 2011 1:28pm
I am nearly sure your issue is that the example assumed has running a package not in ASP.net.
Because under ASP.net runs under the ASP Worker context the events do not fire/propagate the same way.
For the quickest workaround please see the bottom of post http://www.pcreview.co.uk/forums/call-ssis-package-asp-net-2-0-a-t3111900.htmlArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2011 2:31pm
Thank you for your response. The workaround you provided a link for seems to assume that the code is not working. My code is working fine. If there is no error, I get a "Success" message as expected. My problem is that if the SSIS
package fails, all I'm getting is the word "Failure" with no other error detail included, so I don't think it's a security issue.
One task in my SSIS package creates a table in the DB named SSIS_DUPLICATES. To test what happens when this step fails, I created the table manually so that the package would fail. In this scenairo, when I run the debugger to the cursor at the
end this line
WriteLine("Error in {0}/{1} : {2}", source, subComponent, description)
and look in the Locals window, I'm getting the below message next to the "description" parameter:
Executing the query "create table dbo.SSIS_DUPLICATES
(
ID int identit..." failed with the following error: "There is already an object named 'SSIS_DUPLICATES' in the database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,
parameters not set correctly, or connection not established correctly.
This is the error message I want to see in Label2 on my .aspx page, but all I'm seeing is the word "Failure". Does anyone know how I can get the above error message to display instead?
May 12th, 2011 5:00pm
You need to store the messages when th event is raised and then retrieve them when required. Some pseudo code -
Public Class Class1
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult
Dim eventListener As New EventListener()
pkgLocation = _
"C:\Users\test\Desktop\aaaaaaa\Accounting Integration Files\SSIS\Packages\" & _
"Actg Integration\" + Label1.Text
app.PackagePassword = "pwd"
pkg = app.LoadPackage(pkgLocation, eventListener)
pkgResults = pkg.Execute(Nothing, Nothing, eventListener, Nothing, Nothing)
For Each message As String In eventListener.Messages
' Build up a string and displat the messages here
Next
Label2.Text = pkgResults.ToString()
End Sub
End Class
Class EventListener
Inherits DefaultEvents
Public Messages As New Collection<String>
Public Overrides Function OnError(ByVal source As Microsoft.SqlServer.Dts.Runtime.DtsObject, _
ByVal errorCode As Integer, ByVal subComponent As String, ByVal description As String, _
ByVal helpFile As String, ByVal helpContext As Integer, _
ByVal idofInterfaceWithError As String) As Boolean
' Add applicationspecific diagnostics here.
WriteLine("Error in {0}/{1} : {2}", source, subComponent, description)
' Store the message
Messages.Add(String.Format("Error in {0}/{1} : {2}", source, subComponent, description))
Return False
End Function
End Class
http://www.sqlis.com | http://www.konesans.com
Free Windows Admin Tool Kit Click here and download it now
May 13th, 2011 9:51am
Darren, your suggestion worked perfectly. Thank you very much for taking time to reply.
May 13th, 2011 12:06pm