Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I keep getting the following error:

 

************** Start **************

System.Reflection.TargetInvocationException: Property accessor 'CompanyName'

on object

'CRMDataSet+Customer

sRow' threw the following exception:'Cannot get value because it is

DBNull.' ---> System.Data.StrongTypingException: Cannot get value because it

is DBNull. ---> System.InvalidCastException: Cast from type 'DBNull' to type

'String' is not valid.

at Microsoft.VisualBasic.CompilerServices.StringType.FromObject(Object

Value)

at

CustomersRow.get_CompanyName() in CRMDataSet.vb:line 1002

at

CustomersRow.get_CompanyName() in CRMDataSet.vb:line 1004

************** End **************

 

The column in question is allowed to have NULL values, and the records it's crashing on has NULL values in the CompanyName column.

I've tried re-generating the Customers section of the schema but nothing seems to work. The column's .AllowDBNull is True, so that shouldn't be an issue.

 

Can someone please explain what's going on!!

Posted

Horrible!

 

When the XML descriptions of the datatables are generated, these descriptions do NOT contain one specific attribute, which will allow for "isDBNull" Properties to be created.

 

<xs:element name="PRS_GUID" codegen:nullValue="_empty" type="xs:string" />

 

The "codegen:nullValue" part has to be added manually - or program a helper that will do it for you (At least I haven't found a better way yet).

 

What we have done: Written a helper program which will add that attribute to the XML files.

.nerd
  • *Experts*
Posted

I'm not sure about the codegen:nullValue thing. I use the minOccurs property - set it to 0 to allow DBNull values. I would have thought this got put in if you created the table by dragging from server explorer, but haven't it in awhile.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...