Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server (0x80131904): String or binary data would be truncated [duplicate]

I keep getting this error

ErrorSystem.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at workOrder.btnSubmit_Click(Object sender, EventArgs e) in h:\WebSite1\workOrder.aspx.cs:line 60 ClientConnectionId:2b010913-ba9f-4423-b6e1-2e9a038431ce

and googling tells me that a string input is too long to be processed by the database, but all of my fields are large enough and i cant figure this out,

here is my code:

  <!--Removed-->

I get this error even when I leave every nullable field blank and only input 1 character for the rest of the items

Edit: The Table:

<!--Removed-->

Edit:

asp code:

<!--Removed-->

Edit: Removed all code for security,

like image 311
Andrew Diamond Avatar asked May 10 '14 14:05

Andrew Diamond


People also ask

How do I fix String or binary data would be truncated in SQL Server?

To fix this error, patch to SQL Server 2016 SP2, CU6 or newer (including SQL Server 2017), and then turn on trace flag 460. You can enable it at the query level or at the server level.

How do you fix error String or binary data would be truncated?

Solution. To avoid this error and to insert the string with truncation, use the ANSI_WARNINGS option. On setting ANSI_WARNINGS to OFF, the error message will not be displayed and the data will be automatically truncated to the length of the destination column and inserted.

What does String or binary data would be truncated mean in SQL?

The "String or binary data would be truncated" error indicates that the procedure is attempting to store something in the DBServerInfo table that is larger than the column allows. The two known reasons this can occur are: SQL Server has at least one database whose name exceeds 25 characters in length.


1 Answers

This is error occurs when your column size is less than your text size.

For Example : In Database you have column " name varchar(10)" and the size of your data is greater than 10 . At this Situation error is occurred.

EX : If i enter "Siddharth Shukla" in name field than it will give error . so i have to change my column size from 10 to 20.

like image 164
siddharth Avatar answered Oct 01 '22 23:10

siddharth