Tutorial :How to find the Property causing the exception?



Question:

In Linq to SQL SubmitChanges(ConflictMode.ContinueInConflict) i get Exception:

"String or binary data would be truncated. The statement has been terminated."

But how to figure out the Property causing this? I guess i could start testing 1 by 1 the properties but what will happen if i have numerous properties?


Solution:1

Do you have SP1 installed? Looks like this was fixed.

http://social.msdn.microsoft.com/forums/en-US/linqtosql/thread/8a81482c-194a-4a16-8c04-80a27a90e1f4/

Great news... I installed SP1 for .Net 3.5 and guess what... they provide detailed information now!!!

Example: "Cannot insert the value NULL into column 'FullQualifiedUserName', table 'WcmsDevEmpty.Users.Users'; column does not allow nulls. INSERT fails. The statement has been terminated."


Solution:2

You can set the Log property on your data context to be a stream (such as Console.Out or a log file) to effectively profile the SQL being executed


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »