Sqlexception:String or Binary Data Would Be Truncated

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



Leave a reply



Submit