Problem with Try
I have a function that captures an exception and calls a subroutine to save the exception message. Within the called subroutine I have a try catch coded. When I run the program the called subroutine catches the previous exception within its catch portion.
Can you help me and let me know where I'm going wrong.
Here is the code in question:
sHeaderRef = "null"
For Each DataRow In DSXML.Tables(0).Rows
sSQL = "insert into tblDWPHeader " & _
"(CreditorID,BatchNumber," & _
"PacsDocumentCreationDate," & _
"PacsDocumentCreationTime," & _
"NotificationReference) " & _
"values('" & _
DataRow("CreditorID") & "','" & _
DataRow("BatchNumber") & "','" & _
DataRow("PacsDocumentCreationDate") & "','" & _
DataRow("PacsDocumentCreationTime") & "','" & _
DataRow("NotificationReference") & "')"
Command.CommandText = sSQL
Catch e As Exception
ImportMsg(xFullFileName & " - " & e.Message, 2, xConnection)
Private Sub ImportMsg(ByVal xMsg As String, ByVal ErrorLevel As Integer, ByVal xConnection As String)
Dim SQLConn As New SqlConnection(xConnection)
Dim Command As New SqlCommand()
Console.WriteLine("DWP Import Error : " & xMsg)
Command.Connection = SQLConn
Command.CommandText = "exec sp_AddImportMsg '" & _
xMsg.Replace("'", "''") & "', " & ErrorLevel
Catch ex As Exception
Console.WriteLine("ImportMsg failed : " & ex.Message)
Eny Try of the 1st Try block is missing
Still having problem with TRY
Thanks for response. The End Try is present in my code, just did not include within my post.
Still have problem.
The first catch has generated an error. When control is passed to ImportMsg sub routine. The try does not generate a new error, however the catch throws the first error generated by the first catch. How can I code around this??????
By Irina in forum ASP.NET
Last Post: 11-29-2002, 11:47 PM
Last Post: 12-13-2001, 01:06 PM
By Roseta in forum VB Classic
Last Post: 11-14-2001, 04:24 AM
By Ayman in forum VB Classic
Last Post: 04-03-2000, 02:08 AM
By Jason Bock in forum VB Classic
Last Post: 03-21-2000, 07:48 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL