Link to home
Start Free TrialLog in
Avatar of Term56
Term56

asked on

String or binary data would be truncated -- Question

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
Avatar of Atlanta_Mike
Atlanta_Mike

My first guess would be to check the MDAC version?
Avatar of Term56

ASKER

hmm, good idea, let me check
Avatar of Term56

ASKER

ok, my dev box has 2.8 SP1, the release box has 2.8 SP2.

Installe sp2 on mine and recompile ?
Avatar of Term56

ASKER

Is there even a version of 2.8sp2 for windows xp ? looks like it is only for windows 2003
Avatar of Term56

ASKER

on win2k = 2.8 RTM
on win2k3 = 2.8 SP2
on dev box = 2.8 SP1
Avatar of Anthony Perkins
Try psoting the relevant code and structure of the table(s) and we can point out the error.
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Term56

ASKER

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.
Let us know when you find the bug.
Avatar of Term56

ASKER

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.
>>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?
https://www.experts-exchange.com/Databases/Microsoft_SQL_Server/help.jsp#hi67
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.