System.Data.SqlClient.SqlException: String or binary data would be truncated
The error message states the size of a column in invoice
table is less compared to the size of the data being inserted into it.
For example if column brandname
has data type varchar(50)
and you are trying to insert more than 50
characters then it will cause error.
To resolve this compare the size of columns in invoice
with the size of the columns being inserted.
String or binary data would be truncated. The statement has been terminated. System.Data.SqlClient.SqlException (0x80131904)
This exception throws when C#(model) try to save data record for column whose size defined less in SQL SERVER database table where value to pass to this column string length in greater.
To fix this error you only need to alter column of table in SQL SERVER database using SQL Server script.
Only increasing size of column in table works. No need to re deploy the application on PROD/TEST environment.
Database insert error: string or binary data would be truncated
check the length of qry_details table and see if its smaller than the string you send to the db?
basically the exception says you are trying to something bigger than the column length.
Related Topics
A Pattern to Pause/Resume an Async Task
How to Use Datareceived Event of the Serialport Port Object in C#
How to Add the Same Column to All Entities in Ef Core
Can You Compile C# So It Doesn't Need the .Net Framework at Runtime
Foreach Control in Form, How to Do Something to All the Textboxes in My Form
Active Directory Com Exception - an Operations Error Occurred (0X80072020)
How to Calculate the Average Rgb Color Values of a Bitmap
How to Copy Value from Class X to Class Y with the Same Property Name in C#
Asynchronous File Download with Progress Bar
ASP.NET Button Onclick Event Not Firing
How to Disable Cascade Delete for Link Tables in Ef Code-First