How to Trap Errors?

CoastalDataCoastalData Posts: 22
Hello, I've tried several different methods to try and catch the error message generated by sql data compare via the API in VB.Net, and have had no luck at all.

Check out the "catch" below; any suggestions for how better to extract the actual error message? What I've been having to do is to save the sql source to file, and then load that file into Enterprise Manager, and then execute it there to see what's wrong.
Dim executeSql As Boolean = True
                    Dim executor As New BlockExecutor()
                    Try
                        If executeSql Then
                            fnWriteLine("Updating target database")
                            executor.ExecuteBlock(block, "mssql04.discountasp.net", "DB_147089_ktgpdata", False, "DB_147089_ktgpdata_user", "Bulld0g")
                        Else
                            fnWriteLine("Skipping: Updating target database")
                        End If

                    Catch
                        fnWriteLine("The database was NOT updated! See Error Below!")
                        fnWriteLine("Error #:(" & Err.Number & ")" & vbCrLf & "Description: " & Err.Description)
                        fnWriteLine("'GetLast500Errors' Returns this: " & executor.GetLast500Errors.ToString)
                    Finally
                        'Always dispose the SqlProvider's  ExecutionBlock because GetMigrationSQL could throw an exception but still set it
                        block = provider.Block
                        If (TypeOf block Is ExecutionBlock) Then
                            block.Dispose()            'dispose of the objects to delete temporary files    
                        End If
                    End Try

Comments

Sign In or Register to comment.