Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dates and nulls - solution anyone? DotNetNuke.Services.Exceptions.ModuleLoadException: SqlDateTime oDates and nulls - solution anyone? DotNetNuke.Services.Exceptions.ModuleLoadException: SqlDateTime o
Previous
 
Next
New Post
2/2/2007 9:29 AM
 
Currently got quite a few required date fields in the database that are working fine. However, I've had to add 5 optional date fields that are set as allow nulls.

If I set the Date field to Date.MinValue I get:

DotNetNuke.Services.Exceptions.ModuleLoadException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. ---> System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. at System.Data.SqlTypes.SqlDateTime.FromTimeSpan(TimeSpan value) at System.Data.SqlTypes.SqlDateTime.FromDateTime(DateTime value) at System.Data.SqlTypes.SqlDateTime..ctor(DateTime value) at System.Data.SqlClient.MetaType.FromDateTime(DateTime dateTime, Byte cb) at System.Data.SqlClient.TdsParser.WriteValue(Object value, MetaType type, Int32 actualLength, Int32 encodingByteSize, Int32 offset, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues) at TIOS.Modules.BW_SalesInformation.SqlDataProvider.UpdateBW_SalesInformation(Int32 ModuleID, Int32 SaleID, DateTime SaleDate, String SaleTime, DateTime SaleDate2, String SaleTime2, DateTime SaleDate3, String SaleTime3, DateTime SaleDate4, String SaleTime4, DateTime SaleDate5, String SaleTime5, DateTime SaleDate6, String SaleTime6, Boolean SaleClosingClosed, String SaleTitle, DateTime SaleClosingDate, Boolean SaleClosingBySelection, Boolean SaleClosingHasAdditional, String SaleClosingAdditional, String SaleDescription, String SaleWebTitle, String SaleWebDescription, Int32 SaleArea, String HtmlIcons, Boolean Active, Decimal CataloguePrice, Boolean CatalogueOnlinePayments, Boolean Archived) at TIOS.Modules.BW_SalesInformation.BW_SalesInformationController.UpdateBW_SalesInformation(BW_SalesInformationInfo objBW_SalesInformation) at TIOS.Modules.BW_SalesInformation.EditBW_SalesInformation.cmdUpdate_Click(Object sender, EventArgs e) --- End of inner exception stack trace ---

How do I handle the dates correctly so it saves back?
 
New Post
2/2/2007 11:06 AM
 
If the values are null, you will need to send a null value to the database, rather than MinValue.  You can check in your data provider if the value is DateTime.MinValue, and then send DBNull if it is.

You could also change your optional values to Nullable<DateTime> (C# shortcut: DateTime?), which will allow you to set them to null values in code, though you will have to do some extra checking in your code in order to get the value:

DateTime? SaleTime6;
...
if (SaleTime6.HasValue())
{
    lblSaleTime6.Text = SaleTime6.Value.ToShortDateString(CultureInfo.CurrentCulture);
}
else
{
    ...
}

Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
2/2/2007 11:49 AM
 
Cheers worked a dream in SqlDataProvider did:
IIf(SaleDate2.Equals(DateTime.MinValue) = True, DBNull.Value, SaleDate2)

EditModule code on the update did:

                If rSaleDate3.SelectedDate.Equals(rSaleDate3.MinDate) Then
                    objBW_SalesInformation.SaleTime3 = DateTime.MinValue
                Else
                    objBW_SalesInformation.SaleDate3 = rSaleDate3.SelectedDate
                End If

Bear in mind im using telerik datapicker their not a textbox.
 
New Post
5/17/2007 12:27 PM
 

I'm having this same issue when I create a new Calendar module.  Any advice on how to fix this?

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dates and nulls - solution anyone? DotNetNuke.Services.Exceptions.ModuleLoadException: SqlDateTime oDates and nulls - solution anyone? DotNetNuke.Services.Exceptions.ModuleLoadException: SqlDateTime o


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out