Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2009, 07:47 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default BLL Edit Object Class

Never amazes me how I always get a nice little Error Message at the end of my work day.

I have gotten my tables added to the ORM and understand how it all works.

Today I built the Data and Business Classes for them. In one of my tables I have 5 DateTime fields. When I run the app I get an error that states:

Code:
Error 1 Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'. An explicit conversion exists (are you missing a cast?)
for each DateTime field.

I then went and compared my AETransfersEO to the PTORequestEO from the Framework which has an additional DateTime field in the form of RequestDate. The override from both files are identical. I would post my code but it takes 75 arguments and would be really long.

If anyone knows what I missed I would appreciate it. I just get stuck on the error code until I understand what it is telling me. To me it says that it cannot take the Property (@reqDate of type DateTime) and implicitly(understood type) convert it to DateTime. I do not understand what the explicit(direct) conversion is or where it exists. Im sure with time I will figure it out, but I like to share my experience with others so they may learn too.

Thanks

We Learn from Eachother
 
Old March 25th, 2009, 01:35 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

System.DateTime? means it is a nullable data type. I assume your fields allow nulls so the ORM creates the entity object with properties as nullable types and the parameters to the stored procedure are declared to the same way. Make sure you declare the variables in the business classes as nullable also.
 
Old March 25th, 2009, 01:42 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by varallov View Post
System.DateTime? means it is a nullable data type. I assume your fields allow nulls so the ORM creates the entity object with properties as nullable types and the parameters to the stored procedure are declared to the same way. Make sure you declare the variables in the business classes as nullable also.
Ok, that makes sense now. I was thinking System.DataTime? reference the @FieldName parameter, but it means it is nullable. Does this only relate to the DataTime field or are there other DataTypes that can generate this?
Good thing is that I will recognize it in the future.

Thanks
 
Old March 25th, 2009, 02:17 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Nullable types are supported for other intrinsic types as well such as int, byte, double, etc.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the object name within a class Koeno VB.NET 5 July 15th, 2008 01:52 PM
access class object Sheraz Khan ASP.NET 2.0 Professional 0 September 10th, 2007 06:19 PM
Why not using a common detail class for DAL BLL Ghistos BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 April 17th, 2007 01:04 AM
referencing an object in an edit item template dan195 ASP.NET 1.0 and 1.1 Basics 3 September 25th, 2006 07:15 AM
java class edit mode mateenmohd Java GUI 2 March 8th, 2004 06:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.