instead of returning a zero when there's an error, just throw a sqlexception, and that will return the full error message, so you can track it down completely.
if it's a logic error(if.. else return 0), create a string with some diagnostic info, and raise a sql exception with that information.
i could help with some peer review if you want to paste the body of your CLR function .
Try {
// code here
}
catch (SqlException odbcEx) {
// Handle more specific SqlException exception here.
}
catch (Exception ex) {
// Handle generic ones here.
}
Lowell