Click here to Skip to main content
15,892,059 members

string or binary data would be truncated. the statement has been terminated.

surendersinghprajapati asked:

Open original thread
I am getting this error only where a value contains '&'. I don't know why this is happening as '&' operator is ok to insert into SQL server.

Here is the detailed Error log -
VB
System.Data.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated.

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

System.Data.SqlClient.SqlDataReader.get_MetaData()

System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

System.Data.Common.DbCommand.ExecuteReader()

System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)

System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)

System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)

System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicInsert(TrackedObject item)

System.Data.Linq.ChangeDirector.StandardChangeDirector.Insert(TrackedObject item)

System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)

System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)

System.Data.Linq.DataContext.SubmitChanges()
Tags: C# (C# 4.0), .NET (.NET4), ADO.NET, LINQ, ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900