Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBNULL error

Status
Not open for further replies.

ZOEmcai9mh3

Technical User
Apr 3, 2009
1
CA
I am trying to import an xml file into an application.

When I run this code it works fine:


<?xml version="1.0" encoding="utf-8"?>
<Star>
<StarUser INumber="598623457">

<Staff>
<studentNumber>333</studentNumber>
<cpso>888</cpso>

</Staff>
</StarUser>
</Star>


but if I use any other field in place of INumber I get an error:

The Xml Data Import failed : : Object cannot be cast from DBNull to other types.

Here is the relevant part of the schema:



<xs:attribute name="UserId" type="xs:string" use="optional" />
<xs:attribute name="externalId" type="xs:string" use="optional" />
<xs:attribute name="UnivEmployeeId" type="xs:string" use="optional" />
<xs:attribute name="UnivStudentId" type="xs:string" use="optional" />
<xs:attribute name="FirstName" type="xs:string" use="optional" />
<xs:attribute name="LastName" type="xs:string" use="optional" />
<xs:attribute name="BirthYear" type="xs:string" use="optional" />
<xs:attribute name="BirthMonth" type="xs:string" use="optional" />
<xs:attribute name="BirthDay" type="xs:string" use="optional" />
<xs:attribute name="CpsId" type="xs:string" use="optional" />
<xs:attribute name="INumber" type="xs:string" use="optional" />



I thought I should be able to use any these fields as the identifier - but for some reason it only lets me use INumber.
Any Ideas why?
 
That is an application issue, not xml validation issue. If that application is w3c-schema-aware, you can try put up a default, say to empty string or 0 if that is more appropriate, see if it can overcome the casting dbnull in case INumber is absent, which the application seems to be rigidly coded in looking for it and cast it in some way. Like this.
[tt] <xs:attribute name="INumber" type="xs:string" use="optional" default="0" />[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top