Interview Question in SQL Server Integration Services


 

Interview Question :: How Can I catch a Type Mismatch Error in VB.NET


I am a SQL Developer and dont really know .NET that well.

I am creating a custom data flow component for SSIS which performs encryption and decryption on string columns. I have been given the encryption algorithm and didnt write it myself but have adapted it to hook into the data flow pipeline of SSIS.

It works except when the decrypt method runs into a string that isnt actually encrypted. The encrypted value is stored in hex and part of the code converts a hex pair into an integer. This part of the code can generate a typemismatch exception and brings down the whole package.

How can i trap a Type Mismatch error caused by this line of code:

strChar = Chr(CInt("&H" & strChar))

Ideally, I need to direct the failed records down the error pipeline flow but just trapping the error at this stage would be a start.

Thanks.
Answers to "How Can I catch a Type Mismatch Error in VB.NET"
RE: How Can I catch a Type Mismatch Error in VB.NET?

catch ex As InvalidCastException



if you're using a try-catch
 
Vote for this answer ::  
RE: How Can I catch a Type Mismatch Error in VB.NET?

are you using a try/catch wrapper?



Try



' your code here



Catch ex As Exception



MsgBox(ex.toString) ' this will show the error



End Try
 
Vote for this answer ::  
Update Alert Setting