Friday, April 29, 2016

String or binary data would be truncated. EPiServer


Introduction
I had a stressful story 2 days ago. Well, we were at the end of a sprint and like many other projects enjoyed our peaceful time solving a few minor issues that our customer has reported when suddenly we faced the error:
String or binary data would be truncated

I know what you are thinking:
"Yup! OK, Someone used a name longer than 50 char..."

But that was not the story!

How did I check

Fortunately, we were at the end of sprint, so I could check all new properties very fast but there was nothing wrong. I've checked my DB with a query like the one that I used for finding my string in here and checked for strings with len>50. And I've shocked since there was nothing wrong.

Then I've asked my good friends in EPiServer to help meQuan Mai and Daniel Ovaska guided me how to find the cause of the problem.

Faithfully, I had a back up from the last night so I could compare it with my working copy easily using "Visual Studio SQL server database comparison tool" that I've described in here :) and found the problem.


The Problem

As Quan Mai mentioned, when you have mismatch between your code and your DB, you will have this error. Of course I hopped that the error message were more obvious but just keep that in mind :)

Anyways, I've found the problem! Yayyyyy!
We have 2 totally different branches that we are working on for some time and we have a separated DB for each of them. Then I've found the properties of the other one inside my DB....

Why?
Well if you switch your working branch, it will change the web config, but what you don't keep your dlls inside your source control, right? So keep in mind to rebuild your code before browsing your site :)

No comments:

Post a Comment