Falterfire
Falterfire

Reputation: 156

SQLException Obtaining more information

Currently working with converting SQLException error messages into messages that are more useful for the end user. My largest issue has been finding the information I'm looking for.

For instance, error code 8114 is

"Error converting data type [Type1] to [Type2]"

And error code 8152 is

"String or binary data would be truncated"

Using ADO.NET in VB.NET with SQLServer, is there a simple way to figure out which columns are affected by these errors?

Upvotes: 0

Views: 413

Answers (1)

David Parvin
David Parvin

Reputation: 927

The problem is that the error from SQL Server does not give that information so the only way to identify which field is causing the issue is to break apart your SQL statement to run it for the separate fields individually. That sounds like a lot of work for something the developer should be testing to make sure that it does not happen to begin with. There are errors that are not the developer's fault, but the two you listed here are things the developer should be keeping from happening and should be part of the unit tests for the process.

Some of the errors I can think of that are not a developer error, are ones to do with connection errors with SQL Server or corruption errors with the database.

I actually like the fact that my user's can't always figure out what is causing the problem because it tends to force them to tell me there is a problem with my program. If they figure out how to get around an error that I should have fixed, they tend to not tell me there is a problem and sometimes it has been years before I found out there was an issue.

Upvotes: 3

Related Questions