Nullable object must have a value

Posts   
 
    
sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 03-Nov-2006 16:49:14   

Hi, I am using LLBLGen 2.0 using Net2.0 and SQLServer2005. I converted from LLBLGen1.0 to 2.0. Now i am getting all over the projects the error "Nullable object must have a value".I am assgning the DAL values to textboxes.Then i am getting the error.

Please anyone can help me out..

Thanks in advance,

Balaji

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 04-Nov-2006 01:47:04   

Can you post the code that is causing the errors and when the error is being thrown?

sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 06-Nov-2006 06:25:43   

Hi, Here is the code:

EntitydataEntity DALEntityData = new EntitydataEntity(Convert.ToDecimal(strPkID));

objEntityData.TurnOver = DALEntityData.Turnover.Value;

objEntityData.OtherOperatingIncome = DALEntityData.OtherOperatingIncome.Value;

When i assign the DALEntitydata value to myobject(objEntitydata) it's giving the "Nullable object must have a vale".

I am converting LLBLGen 1.1 VStudio 2003 project to LLBLGen 2.0 Vstudio2005 project using target platform 2.0.

Can you please suggest me how to solve this? It's a urgent one...

Thanks in advance, Balaji

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Nov-2006 07:46:07   

There are some information missing in your form, please read the following guide: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722

I'm assuming you are using the SelfServicing model. You did not specify which line of code produces the exception/error.

sbalaji123
User
Posts: 26
Joined: 13-Oct-2006
# Posted on: 06-Nov-2006 11:36:44   

Hi,

Designer:

I am using LLBLGenpro 2.0.0.0 Final(July6th, 2006).

It refers C:\Program Files\Solutions Design\LLBLGen Pro v2.0\RuntimeLibraries\DotNET20\SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll. Runtime Version:v2.0.50727 Version:2.0.0.0

StackTrace:StackTrace = " at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)\r\n at System.Nullable`1.get_Value()\r\n at CDMS.BLMGR.EntityDataBLMGR.GetSelectedRecord(String strPkID) in D:\CDMS435\DesktopModules\CDMSModules\Components\CDMS.B...

Template group:Selfservicing TargetPlatform:.NET2.0 Database type:SQLServer2005 CTP SelectedPreset:SD.Presets.SelfServicing.Twoclasses2005 AddTasksstuck_out_tongue_winking_eye redicateFactory & SortFactory

Here is the code:

EntitydataEntity DALEntityData = new EntitydataEntity(Convert.ToDecimal(strPkID));

objEntityData.TurnOver = DALEntityData.Turnover.Value;

objEntityData.OtherOperatingIncome = DALEntityData.OtherOperatingIncome.Value;

When i assign the DALEntitydata OtherOperatingIncome value to myobject(objEntitydata) it's giving the ERROR MESSAGE "Nullable object must have a vale".

Please help me out asasp..

Thanks in advance, Balaji

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 06-Nov-2006 12:36:28   

change: objEntityData.TurnOver = DALEntityData.Turnover.Value; into if(DALEntityDaata.Turnover.HasValue) { objEntityData.TurnOver = DALEntityData.Turnover.Value; }

The reason for this is that Turnover is a nullable type. Please read more about nullable types in the .NET 2.0 C# documentation. If you don't want nullable types, please uncheck the checkbox in teh designer for this field or run the plugin to bulk-set this flag for all your fields.

Frans Bouma | Lead developer LLBLGen Pro