Page 1 of 1
String or binary data would be truncated Error
Posted: Wed May 28, 2008 9:42 am
by mbelle
Hi,
I am making updates to my products through the admin interface and when I click the "save" button, I receive the following error:
String or binary data would be truncated.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Upon further testing, I believe this has to with the fact that I have too many characters in the name field. When I delete a view characters, I am able to save the product page. Is there anyway I can adjust the settings to that the name fields accepts more characters?
Re: String or binary data would be truncated Error
Posted: Wed May 28, 2008 10:10 am
by sohaib
Upon further testing, I believe this has to with the fact that I have too many characters in the name field. When I delete a view characters, I am able to save the product page. Is there anyway I can adjust the settings to that the name fields accepts more characters?
Name field in RC3 accepts 100 characters. We have already updated it to 255 characters in our latest revisions.
You can also make this change manually by opening the database and changing the size of Name field in ac_Products table. It should not affect anything else.
Code: Select all
ALTER TABLE ac_Products ALTER COLUMN [Name] nvarchar(255) NOT NULL
Re: String or binary data would be truncated Error
Posted: Wed May 28, 2008 10:36 am
by mbelle
Hi,
I made the suggested change to the "name" column, but I'm still having the same issue when trying to modify the product page. It will only allow me to enter up to 100 characters.
Is there anything else I need to modify?
Re: String or binary data would be truncated Error
Posted: Wed May 28, 2008 10:45 am
by sohaib
I see...
You can edit the following files and set MaxLength="255" for name field
Admin/Products/EditProduct.aspx
Admin/Products/AddProduct.aspx
Re: String or binary data would be truncated Error
Posted: Wed May 28, 2008 2:43 pm
by mbelle
Hi I edited the two product files and am still having the same issue. I put debugging on and am attaching the details below:
Server Error in '/' Application.
--------------------------------------------------------------------------------
String or binary data would be truncated.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
Source Error:
Line 194:
Line 195: //SAVE PRODUCT
Line 196: _Product.Save();
Line 197: SavedMessage.Visible = true;
Line 198: SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow);
Source File: c:\Inetpub\wwwroot\AbleCommTest\Admin\Products\EditProduct.aspx.cs Line: 196
Stack Trace:
[SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +149
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command) +131
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command) +131
CommerceBuilder.Products.Product.BaseSave() +12337
CommerceBuilder.Products.Product.Save() +652
Admin_Products_EditProduct.SaveButton_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AbleCommTest\Admin\Products\EditProduct.aspx.cs:196
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +90
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +76
System.Web.UI.WebControls.LinkButton.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) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
Re: String or binary data would be truncated Error
Posted: Thu May 29, 2008 2:29 am
by sohaib
Are you sure its product name field that exceeds the field size?
What kind of names are you entering for example?
Are you using SQLServer 2005 or SQLServer 2000?
Re: String or binary data would be truncated Error
Posted: Thu May 29, 2008 10:21 am
by mbelle
Yes, I'm sure. When a delete characters from the name field I am able to save the product record.
I am using SQL Server 2005.
Re: String or binary data would be truncated Error
Posted: Thu May 29, 2008 10:24 am
by mbelle
Our products are titles of books. An example name field is:
A Teacher's Guide to Including Students with Disabilites in General Physical Education, Third Editio
I am able to add the "n" to Third Editio in the name field, but receive the error when I attempt to save.
Re: String or binary data would be truncated Error
Posted: Thu May 29, 2008 10:39 am
by sohaib
Please make sure that length of Name field in products table is really set to 255 characters because the name you posted as example is 100 characters. As soon as you enter 101th character it gives error. I would assume that database field is not yet updated correctly.
Re: String or binary data would be truncated Error
Posted: Fri May 30, 2008 9:17 am
by mbelle
Hi,
I doublechecked that the name field was set to 255 in the database and even entered the following record directly into the database with a name that has more than 100 characters and it saved in the database:
"The Teacher's Guide to The Teacher's Guide The Teacher's Guide The Teacher's Guide The Teacher's Guide The Teacher's Guide The Teacher's Guide"
Re: String or binary data would be truncated Error
Posted: Tue Jun 03, 2008 4:48 pm
by Logan Rhodehamel
I tracked down the error. If you want to quickly patch your install, you can extend these fields in ac_Products table:
IconAltText
ThumbnailAltText
ImageAltText
Set these fields to nvarchar(255) to match the title. Then you will be able to add products with names longer than 100 characters.
Re: String or binary data would be truncated Error
Posted: Wed Jun 11, 2008 2:54 pm
by mbelle
That did the trick.
Thanks!