Kieron Posted February 18, 2003 Posted February 18, 2003 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!! Quote
Heiko Posted February 18, 2003 Posted February 18, 2003 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. Quote .nerd
*Experts* Nerseus Posted February 21, 2003 *Experts* Posted February 21, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.