0
votes

I get the following exception when inserting data into SQL Server database.

System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
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)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at SubjectDataAccess.InsertUrls(String url, String urltitle, String urldetails, String favicon, String imagedata) in d:\project\New Folder\March 5\March 5\ProfileTenModified\App_Code\SubjectsDataAccessLayer\SubjectDataAccess.cs:line 723}

The data is

Url:

http://www.mnn.com/earth-matters/space/photos/10-places-on-earth-that-resemble-alien-planets/etosha-pan-namibia

Title:

10 places on Earth that resemble alien planets: Etosha pan, Namibia

does the 10 is in the beginning cause an issue...

1
what is the size of the table column, is it smaller than the data?Mahmoud Darwish
I have set them to nvarchar (max)..Spirals Whirls
what about the parameter if you are using oneMahmoud Darwish
command parameter, please edit the question and put your codeMahmoud Darwish
yes you are right problem with the Datatype. it is not max as I expected .. ThanksSpirals Whirls

1 Answers

1
votes

Make sure that the data is smaller than the data size on your table