I was creating a simple tool to work with database table. When I coded a part of updating table records I got some errors. One of them was:

Fixing C# and GridView error - String or binary data would be truncated. The statement has been terminated

The code of updating is rather simple in the void GridView1_RowUpdating:

 

But when I pressed “Update” button, I got the error on screen:

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

I spent a lot of time, but solution was easier. I used to check the maximum allowed length of my columns. So, when I created table, I have forgotten to set varchar lengths for Name and Country fields. And their lengths where "1", that’s why I couldn’t update my records. Of course, if I haven’t entered only 1 symbol.

Here’s the code for creating table: