Copied to clipboard

Flag this post as spam?

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


  • Accusoft 58 posts 109 karma points
    May 03, 2011 @ 14:51
    Accusoft
    0

    Changing database data type of custom data type

    I built a new custom data type for a module I'm working on that basically saves a list of ID's to the database. It was working great but recently I started receiving this error:

    
    Conversion failed when converting the nvarchar value '1071,1075' to data type int.
    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: Conversion failed when converting the nvarchar value '1071,1075' to data type int.
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    [SqlException (0x80131904): Conversion failed when converting the nvarchar value '1071,1075' to data type int.]
    

    It appears that it's trying to store it in an INT field in the database. I didn't specify this as an int field and don't know where to change it. The module only has 4 files and I didn't see it specified anywhere. How can I fix this to store as a ntext or nvarchar? Thank you !

  • Eran Meir 401 posts 543 karma points
    May 03, 2011 @ 15:46
    Eran Meir
    0

    go to developer section --> Data types --> Your Data Type 
    now change "Database datatype" to Nvarchar.
    good luck :)

  • Accusoft 58 posts 109 karma points
    May 03, 2011 @ 15:48
    Accusoft
    0

    Hi Eran,

    Database datatype is not an option for my data type.  It's a custom data type so I can add it, but I don't know how.

  • Eran Meir 401 posts 543 karma points
    May 03, 2011 @ 15:52
    Eran Meir
    0

    ok i found a solution which sounds right http://our.umbraco.org/forum/developers/api-questions/14870-Error-when-using-macro-picker-datatype
    see Robert Foster solution :)

  • Accusoft 58 posts 109 karma points
    May 03, 2011 @ 16:31
    Accusoft
    0

    Hi Eran,

    Thank you, this post was very informative.  I followed Robert's advice on this and am experiencing the same problem (the field defaults to "date").  The problem I'm having now is when I switch back to my custom data type, it's overwriting the field default at some point.  Is there any way to actually build this drop-down into my custom data type?

     

  • Eran Meir 401 posts 543 karma points
    May 03, 2011 @ 16:40
    Eran Meir
    0

    what do you mean the field default ?

  • Accusoft 58 posts 109 karma points
    May 03, 2011 @ 16:52
    Accusoft
    0

    If anyone is interested, in your PrevalueEditor.cs file in the "OnSave" action is a line similar to "_datatype.DBType = (umbraco.cms.businesslogic.datatype.DBTypes)Enum.Parse(typeof(umbraco.cms.businesslogic.datatype.DBTypes), _lstDataType.SelectedValue, true);"  Make sure the _lstDataType.SelectedValue is set to the value you need. 

Please Sign in or register to post replies

Write your reply to:

Draft