Welcome to the Community Exchange

Welcome to the Community Exchange, a place where community members can exchange questions and answers related to DotNetNuke. If you would like more info about the Community Exchange, please visit this page in our Wiki. 

CreatedOnDate not loading for database in custom module

I am new to DNN, and have built my first site with custom skins, containers & modules. For the most part I have figured out the issues I have ran into....except one. I followed the DotNetNuke Explained video on creating a module, watched all of the Task Manager series, downloaded and used the Visual Studio Module template and even dowloaded and read through the Task Manager code.

After writing my module, everything works great except the CreatedOnDate and LastModifiedOnDate fields are both giving me a null date (1/1/0001). Both dates are being written to the database with no problem and the LastModifiedOnDate is even being updated when I update my content object. 

My content Object is ADTVVideo which inherits from ContentItem Which inherits from BaseEntityInfo. BaseEntityInfo has  CreatedOnDate/LastModifiedOnDate fields but they are read only and don't seem to do anything. The module template has new fields created for these values. In my ADTVVideo class I have an override of the Fill method that calls the base method then fills the fields I created from the datareader. All of my fields populate except for the two dates. My fill code contains:

CreatedOnDate = Null.SetNullDateTime(dr["CreatedOnDate"]);
         LastModifiedOnDate = Null.SetNullDateTime(dr["LastModifiedOnDate"]);

Yet when I read my two fields they both contain the null date. Any ideas?


asked 5/25/2012
DigitalVir6
DigitalVir

2 Answers

I have a related but very easy (hopefully) question involving SetNullDateTime:I have looked (but have not found so far) any documentation that shows that you can use SETDATETIME to fill in a DATE field. I've seen something similar done on other systems, where the longer SETDATETIME field would fill in the first portion of the DATE field (and throw the time-remainder into the bit bucket).Can I use SETDATETIME to fill in SETDATE in this manner in a C# program ???Sorry, but I'm a newbie on Microsoft.THANKS FOR YOUR HELP.Jeff
answered 10/13/2012 Jeff McVey 5
Jeff McVey

at a glance that should work, however we use a different pattern -rather than doing the individual columns in the overriden fill method (the IHydratable implementation), we call the FillInternal method of BaseEntityInfo e.g.

public override void Fill(IDataReader dr)
        {
            //Call the base classes fill method to populate base class properties
            base.FillInternal(dr);

//now fill other fields e.g.

//ModuleTitle = Null.SetNullString(dr["ModuleTitle"]);

//etc.

}

answered 5/25/2012 cathal connolly 1210
cathal connolly

Your Answer

In order to provide an answer to this question, you must Login

I am flagging this question because...




10 inform moderator flags remaining

I am deleting this question because...




I am flagging this answer because...




10 inform moderator flags remaining

Flagging a Post

You have already flagged this post. Clicking "Remove Flag" below will remove your flag, thus reducing the count by one as well.

I am deleting this answer because...




DotNetNuke Corporation

DotNetNuke (DNN) provides a suite of solutions that make designing, building and managing feature-rich sites and communities fast, easy and cost-effective. The DotNetNuke Platform CMS is the foundation for more than one million websites worldwide. DNN Social, our newest solution, enables businesses to create immersive, interactive communities. Thousands of organizations like True Value Hardware, Bose, Cornell University, Glacier Water, Dannon, Delphi, USAA, NASCAR, Northern Health and the City of Denver have leveraged DNN to deploy highly engaging business- critical websites. Our rapid growth in product sales and deployments resulted in DotNetNuke Corp. being named one of the fastest growing private companies in America by Inc. Magazine in 2011 and 2012.