?
Solved

String or binary data would be truncated -- Question

Posted on 2006-05-11
13
Medium Priority
?
5,301 Views
Last Modified: 2008-01-09
I know the general reason this happens. But it makes no sense why it is happening to me. I have a .net app I developed on a windows xp machine. I created a package, and deployed it to win2k/win2k3 -- and for some reason when I run it on that box, which manipulates the same database, and does the same insert/update it fails. Could it be a dll issue ?

I know for a fact the string is well formed and the database contains the correct columns, because it works on my xp box. Any suggestions ?

this is what I get :

[SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857242
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734854
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
   vt_enhancements.WebForm1.btnUpdate_Click(Object sender, EventArgs e) +1900
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
0
Comment
Question by:Term56
13 Comments
 
LVL 13

Expert Comment

by:Atlanta_Mike
ID: 16661066
My first guess would be to check the MDAC version?
0
 

Author Comment

by:Term56
ID: 16661129
hmm, good idea, let me check
0
 

Author Comment

by:Term56
ID: 16661163
ok, my dev box has 2.8 SP1, the release box has 2.8 SP2.

Installe sp2 on mine and recompile ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Term56
ID: 16661219
Is there even a version of 2.8sp2 for windows xp ? looks like it is only for windows 2003
0
 

Author Comment

by:Term56
ID: 16661237
on win2k = 2.8 RTM
on win2k3 = 2.8 SP2
on dev box = 2.8 SP1
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16664337
Try psoting the relevant code and structure of the table(s) and we can point out the error.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16664343
0
 
LVL 28

Accepted Solution

by:
rafrancisco earned 1500 total points
ID: 16667868
Based on the following links:

http://www.sql-server-helper.com/faq/error-messages-p05.aspx
http://www.sql-server-helper.com/error-messages/msg-8152.aspx

The usual cause of this problem is that you are trying insert or update a column where the length of the column is not long enough to accommodate the length of the value being inserted to it.
0
 

Author Comment

by:Term56
ID: 16669069
I understand the usual case. But I can assure you it is not an issue in relation to the code/tables. It works perfectly fine on my dev box, and I have been able to get it working on a test enviornment. I checked the mdac and versions of the framework and all three have the current versions needed.

It has something to do with the server and/or deployment.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16672279
Let us know when you find the bug.
0
 

Author Comment

by:Term56
ID: 16683859
I unfortunately have not been able to find an answer. I am rebuilding a new web server and hopefully the problem will go away. I dont know how to handle this ticket, as I dont think it should PAQ'ed -- wont help anyone else.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16687204
>>I dont think it should PAQ'ed -- wont help anyone else.<<
As everyone has pointed out the error message is self-explanatory.  See here:

What are my choice?
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi67
0
 

Expert Comment

by:TSGSJeremy
ID: 24764447
FWIW - I started getting this error today after running perfectly fine for months. Turns out I had a table with two varchar(max) columns. Don't know what caused it, but today the first column was still varchar(max) however the second column had been converted to a varchar(1). For now I set both to varchar(6000) and it is working, but if it breaks again I guess I'll have to split the columns into two tables.

It should also be pointed out that this is a GoDaddy shared SQL2005 installation.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question