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 !
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?
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.
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:
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 !
go to developer section --> Data types --> Your Data Type
now change "Database datatype" to Nvarchar.
good luck :)
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.
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 :)
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?
what do you mean the field default ?
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.
is working on a reply...