I have a problem with this:
String or binary data would be truncated
And this is my coding:
String savePath = @"C:\Users\Shen\Desktop\LenzOCR\LenzOCR\WindowsFormsApplication1\ImageFile\" + fileName;
inputImageBox.Image = Image.FromFile(ImageLocation);
inputImageBox.Image.Save(savePath);
String sqlData = "INSERT INTO CharacterOCR(ImageName, ImagePath, Character, CharacterDescription)
VALUES('"+fileName+"', '"+savePath+"', '"+typeName+"', '"+CharDesc+"')";
SqlCommand cmd = new SqlCommand(sqlData, con);
cmd.ExecuteNonQuery(); // <<<<<error indicates here
What is the problem?
Look at the schema of your table and look at the max lengths. You're probably trying to insert something larger than the max length.
That just means that one of the values you're trying to cram into a column is too long for the data type you've defined for that column.
For example, trying to INSERT "Hello" to a column that's only a VARCHAR(4).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With