Copied to clipboard

Flag this post as spam?

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


  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Aug 13, 2018 @ 15:44
    Ravi Motha
    0

    String or binary data would be truncated: for textArea

    I have a function to help my editors publsh keywords based n existing child content:

    However what ever I do i end up hitting a String or binary data would be truncated...

    I am getting a Node

      var rs = ApplicationContext.Current.Services.ContentService;
                        var content = rs.GetById(NodeId);
    

    populating the properties for the IContent node

     KeywordsList.AddRange(dCurrentKeyWords);
                        if (dContent.HasProperty("supplierKeyWords")) {
                            string xyz = string.Join(",", KeywordsList);
                            dContent.Properties["supplierKeyWords"].Value = xyz;
                    }
    

    Yes I tries it as dContent.SetValue("supplierKeyWords") and then trying to pubilsh the updated value

      try
                        {
                            rs.SaveAndPublishWithStatus(dContent, 0, false);
                            return true;
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Info<ContentService>("There was issue with Keywords in DMC Suppliers  (DMC: " + ContentNode.Name + ") :Keywords" + KeywordsList + " Error ::" + ex);
                            return false;
                        }
    

    and I get a error: String or binary data would be truncated it looks related to this error: but I've tried it with textArea, textbox and tags https://our.umbraco.com/forum/core/general/40332-Unable-to-publish-String-or-binary-data-would-be-truncated

    I'm obviously reluctant to tweak the database.. unless absolutely necessary.. I'm running 7.7.6 and i can't see any obvious reason why i can't save the string

    Ravi

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Aug 13, 2018 @ 15:52
    Nik
    0

    Ravi,

    Have you tried catching the specific error and then outputting the value of xyz to a console so you can view it's actual length? That would be my first step to see if it is working in some situations but not others. Also to identify the length that is triggering the error.

    Cheers

    Nik

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Aug 13, 2018 @ 17:01
    Ravi Motha
    0

    so when I do a watch:

    xyz has a value of "Dallas, US, UnitedStates Of America, Jacksonville, Tampa, Orlando" I just trying to see what is wrong with the data datatype..

    I keep seeing it has an id of 0 in the properties..

    almost like its not there..

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Aug 13, 2018 @ 17:25
    Nik
    0

    What values do the other properties have as ID values? Are they populating correctly?

  • Steve Ayres 3 posts 74 karma points
    Aug 14, 2018 @ 13:04
    Steve Ayres
    0

    I certainly don't profess to understanding much Umbraco coding (I'm a DB man), but last time I saw this error it was related to this issue:

    https://our.umbraco.com/forum/core/general/40332-Unable-to-publish-String-or-binary-data-would-be-truncated

    Running this on my DB resolved it: ALTER TABLE dbo.cmsPropertyData ALTER COLUMN dataNvarchar nvarchar(max)

    Whether that's a good/best approach I'm really not sure!

    Steve

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Aug 14, 2018 @ 13:07
    Ravi Motha
    0

    I'm trying to do that as a last resort..I don't like the idea of db changes if i can avoid them.

    Thanks

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Aug 20, 2018 @ 09:28
    Ravi Motha
    100

    After much fiddling and and so forth. someone had stuffed up strings and I was pointing to a different umbraco instance with out the correct fields etc.. ie metaKeywords instead of KeyWords

Please Sign in or register to post replies

Write your reply to:

Draft