Copied to clipboard

Flag this post as spam?

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


  • Christopher 23 posts 96 karma points
    Mar 15, 2013 @ 12:59
    Christopher
    0

    Custom data type publishing error "Conversion failed when converting date and/or time from character string."

    Hi,

    I have been working on a custom datatype, but am having a few problems when it comes to publishing nodes which contain this data type.

    The error I am getting is as descriped in the subject.  I have stripped back the code to the most basic implementation of a data type and still cant manage to get it to save without error, I am thinking the problem may be somewhere else but I am not sure.  I have also included the stack trace, any suggestions would be greatly appreciated as I am out of ideas.  Would be nice to get it working before the weekend :)

    Thanks.

     

    Chris.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco.cms.businesslogic.web;
    using umbraco.NodeFactory;
    using System.Xml.XPath;
    using BMT.Library.Razor.CategoryFilter;

    namespace Namespace
    {

        public partial class CategoryAssociation : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
        {

            public string umbracoValue;

            protected void Page_Load(object sender, EventArgs e)
            {

                if (Page.IsPostBack)
                {

                    umbracoValue = "Test String";

                }

            }

            public object value
            {
                get
                {
                    return umbracoValue;
                }
                set
                {
                    umbracoValue = value.ToString();
                }

            }

        }

    }

     


    [SqlException (0x80131904): Conversion failed when converting date and/or time from character string.]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +404
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2660
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6431293
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +6432994
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +538
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +689
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +327
       Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) +167
       umbraco.DataLayer.SqlHelper`1.ExecuteNonQuery(String commandText, IParameter[] parameters) +150
    
    [SqlHelperException: Umbraco Exception (DataLayer): SQL helper exception in ExecuteNonQuery]
       umbraco.DataLayer.SqlHelper`1.ExecuteNonQuery(String commandText, IParameter[] parameters) +261
       umbraco.cms.businesslogic.datatype.DefaultData.set_Value(Object value) +1229
       umbraco.controls.ContentControl.saveClick(Object Sender, ImageClickEventArgs e) +185
       umbraco.controls.ContentControl.savePublish(Object Sender, ImageClickEventArgs e) +24
       System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +187
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +165
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707

     

  • Christopher 23 posts 96 karma points
    Mar 15, 2013 @ 13:07
    Christopher
    101

    Hello all,

     

    As you would expect, a helpful colleague pointed out the schoolboy error immediately after posting.  Still, I will post an answer as it might help someone else who is being equally daft.

    The type of value stored in the database is set under the datatype settings on the developer tab.  I had mine set to Date rather than text.

    Regards,

     

    Chris.

     

Please Sign in or register to post replies

Write your reply to:

Draft