Unable to cast object of type 'System.DBNull' to type 'System.Byte[]


Author
Message
MarcoR
MarcoR
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 15, Visits: 39
Hi, I am reading an image field from the database into a property of type[]. When the field is null, I get an Unable to cast object of type 'System.DBNull' to type 'System.Byte[]  error. I have changed the StrataFrame generated code for the BO to fix it, but is there some setting that I need to make when generating the BO so this is automatically handled correctly in the generated BO? BigGrin
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm not sure if one of the "return alternate on null" settings would work in this situation, but you could just put your custom code in the custom code area of the BO Mapper (the big text box at the bottom of the field customization form). That way every time your BO is rebuild within the mapper, this code gets used.
MarcoR
MarcoR
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 15, Visits: 39
Thanks! I used new byte[] {} in the alternate and that worked.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Cool!
Peter Jones
Peter Jones
Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Guys,

FYI we use "return alternate on null > Nothing" for TimeStamp columns and that works fine to.

I say this because I'm pretty sure the we get a "System.DBNull' to type System.Byte[]" error if we don't get the Timestamp setting correct in the BO Mapper.

Cheers, Peter

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search