SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Error handling


Error handling

Author
Message
kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5234 Visits: 2767
Hi all,

I want to do error handling using Script task in contril flow task.
I have a table in my database to store information when any error occurs.

So, how can I insert error message from SSIS into my database table?

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5234 Visits: 2767
I tried in this manner but its not working..............
Public Sub Main()

Dim iErrorCode As Integer = _
Convert.ToInt32(Dts.Variables("ErrorCode").Value)
Dim sErrorDescription As String = _
Dts.Variables("ErrorDescription").Value.ToString
Dim sSourceName As String = _
Dts.Variables("SourceName").Value.ToString
Dim sSubComponent As String = _
"OnError Event Handler"
'Dim sMsg As String = "Source: " & sSourceName & vbCrLf & _
' "Error Code: " & iErrorCode.ToString & _
' vbCrLf & _
' "Error Description: " & _
' sErrorDescription


'MsgBox(sMsg, , sSubComponent)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
myConnection = New SqlConnection("server = localhost ;uid = sa; pwd = 123; database = eCareProDB")
myConnection.Open()
myCommand = New SqlCommand("INSERT INTO DATALOAD_ERROR_LOG(EL_ErrorCode,EL_ErrorDescription) VALUES (iErrorCode, sErrorDescription)")
myCommand.ExecuteNonQuery()
myConnection.Close()



Dts.TaskResult = ScriptResults.Success
End Sub

Plese suggeset

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
SQLCJ
SQLCJ
Say Hey Kid
Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)

Group: General Forum Members
Points: 689 Visits: 576
Did you try using SSIS log provider for SQL server ?
SQLCJ
SQLCJ
Say Hey Kid
Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)Say Hey Kid (689 reputation)

Group: General Forum Members
Points: 689 Visits: 576
Please take a look at
http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/95353/
kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5234 Visits: 2767
But I have to insert in sql table only...

I am getting error in my code below:
Public Sub Main()

Dim iErrorCode As Integer = _
Convert.ToInt32(Dts.Variables("ErrorCode").Value)
Dim sErrorDescription As String = _
Dts.Variables("ErrorDescription").Value.ToString
Dim sSourceName As String = _
Dts.Variables("SourceName").Value.ToString
Dim sSubComponent As String = _
"OnError Event Handler"
'Dim sMsg As String = "Source: " & sSourceName & vbCrLf & _
' "Error Code: " & iErrorCode.ToString & _
' vbCrLf & _
' "Error Description: " & _
' sErrorDescription


'MsgBox(sMsg, , sSubComponent)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
myConnection = New SqlConnection("server = localhost ;uid = sa; pwd = 123; database = eCareProDB")
myConnection.Open()
myCommand = New SqlCommand("INSERT INTO DATALOAD_ERROR_LOG(EL_ErrorCode,EL_ErrorDescription) VALUES (" + Dts.Variables(iErrorCode).Value + "," + Dts.Variables(sErrorDescription).Value + ")", myConnection)
myCommand.ExecuteNonQuery()
myConnection.Close()

'MsgBox(myConnection, MsgBoxStyle.Exclamation)

Dts.TaskResult = ScriptResults.Success
End Sub


Error:
  at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5234 Visits: 2767
can someone tell me why I am getting this error:
Conversion from string "INSERT INTO DATALOAD_ERROR_LOG(E" to type 'Double' is not valid.

Both columns EL_ErrorCode,EL_ErrorDescription are of datatype nvarchar(1000)

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search