Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 23, 2014 @ 11:56
    Jeroen Breuer
    0

    String or binary data would be truncated with custom property editor

    Hello,

    I'm developing a property editor which needs to save JSON. For now I just have some hard coded JSON and I'm trying to save that to see if it works, but that already gives me the following exception:

    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. 
    
    Stack Trace: 
    
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       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, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteScalar()
       at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:line 299
       at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClassa.<ExecuteScalarWithRetry>b__9()
       at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
       at Umbraco.Core.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco)
       at Umbraco.Core.Persistence.Database.Insert(Object poco)
    
    This is my package.manifest:
    {
        propertyEditors: [      
            {
                alias: "EditPhase",
                name: "Edit phase",
                editor: {
                    view: "~/App_Plugins/EditPhase/editphase.html",
                    hideLabel: true,
                    valueType: "JSON"
                }
            }
        ]
         ,
        javascript: [
            '~/App_Plugins/EditPhase/editphase.controller.js',
            '~/App_Plugins/EditPhase/editphase.resource.js'
        ],
        css: [
            '~/App_Plugins/EditPhase/main.css'
        ]
    }
    And this is the controller with the hard coded JSON:
    angular.module("umbraco").controller("EditPhaseController",
        function ($scope, editPhaseResource, editorState) {
    
            $scope.model.value = {
                buildings: [
                    {
                        "number": 60,
                        "type": {
                            "key": "1203",
                            "label": "Hoekwoning"
                        },
                        "price": 1289,
                        "housearea": 1290,
                        "volume": 664,
                        "landarea": 300
                    },
                    {
                        "number": 25,
                        "type": {
                            "key": "4703",
                            "label": "Vrijstaand"
                        },
                        "price": 49,
                        "housearea": 66,
                        "volume": 876,
                        "landarea": 203
                    }
                    ,
                    {
                        "number": 1,
                        "type": {
                            "key": "4703",
                            "label": "Vrijstaand"
                        },
                        "price": 49,
                        "housearea": 66,
                        "volume": 876,
                        "landarea": 203
                    }
                ]
            };
    
        });
    I've already seen more topics about this, but valueType is already set correct and I tried rebuilding the site, restarting the app pool, clearing your browser cache, and restarting the website. Nothing seems to work. Any ideas? I'm on Umbraco 7.1.8.
    Jeroen
  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 23, 2014 @ 13:10
    Jeroen Breuer
    0

    When I look into the database the value is still being stored in the dataNvarchar column. No matter what I try it won't save in the dataNtext column.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 23, 2014 @ 13:22
    Jeroen Breuer
    101

    I found the solution in this topic: http://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/46784-Changes-to-valueType-not-reflected-in-db#comment167619

    After chaning the valueType you also need to recreate the datatype.

    I've created an issue for this: http://issues.umbraco.org/issue/U4-6050

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft