Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Vetrivel 1 post 71 karma points
    Dec 11, 2020 @ 07:04
    Vetrivel
    0

    String or binary data would be truncated

    Hi Team,

    We are facing an SQL error with saving property values in Umbraco v7.15.6.

    We checked with the database, the values try to save in dbo.cmsPropertyData under dataNvarchar property. the property set as nvarchar(500) , that's the issue, once the input valued limit exceeds 500 it will throw the error.

    We can directly update the field datatype in SQL direct query, but we are not preferred that, is there any other ways to handle this, or

    Is this issue fixed in some other Upgraded Umbraco versions, If so we need the upgraded Umbraco version name details?

        [API] Exception was thrown in class 'SqlConnection' while invoking method 'OnError', with the message: 'String or binary data would be truncated.
    The statement has been terminated.'.
    System.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated.
    The statement has been terminated.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    
  • Tom 3 posts 73 karma points
    Jul 14, 2021 @ 21:38
    Tom
    0

    Hey, not sure if you're still working on this, but I ran in to a similar issue on 8.12. I was bumping up against that nvarchar(512) limit, but only occasionally and only by a relatively slim margin. I noticed that the JSON object was being stored with whitespace I didn't need, so I stripped that out by stringifying my object when it was submitting instead of submitting just the rendermodel.

    I went from this:

    $scope.$on('formSubmitting', function() {
        $scope.model.value = $scope.renderModel;
    }
    

    to this:

    $scope.$on('formSubmitting', function() {
        $scope.model.value = JSON.stringify($scope.renderModel);
    }
    

    Your mileage may vary depending on what your object looks like, but in my case the built-in minification from JSON.stringify() was enough to solve my problem.

  • Mark Drake 133 posts 457 karma points c-trib
    Jul 15, 2021 @ 03:49
    Mark Drake
    1

    I've ran into this when defining a custom data type and the valueType is set to STRING.

    The fix was to set this value to TEXT. When I made this update, the value was stored as ntext and had plenty more than 500 characters.

    Documentation for this here.

  • Tom 3 posts 73 karma points
    Jul 15, 2021 @ 13:53
    Tom
    0

    Good to know, thanks for pointing that out!

    Is there any concern with existing data when that type is changed to text? I had considered that approach, but was worried about unforeseen consequences.

  • Chris Ashton 57 posts 89 karma points
    Dec 22, 2021 @ 20:21
    Chris Ashton
    0

    For what it is worth, or next time I Google this... it seems fine to change the 'valueType' from 'STRING' to 'TEXT'.

    I did this via the package.manifest but I also manually updated the 'cmsDataType' table as I believe this is only written to when the property editor is first installed.

    This process appears to be non-destructive. In fact querying ''cmsPropertyData' it is possible to see old values saved in the 'dataNvarchar' column, and new values saved after making the above change in the 'dataNtext' column.

    Chris

    Umbraco version 7.15.6

Please Sign in or register to post replies

Write your reply to:

Draft