Link to home
Start Free TrialLog in
Avatar of Wil999
Wil999Flag for Netherlands

asked on

VB.NET - Error on datatable.readxml (unable to read integer fields with NULL value)

Hi,

I am trying to load a XML file into a datatable with the datatable.readxml method, but i am getting an error because some integer fields have no value in the XML File.

Before reading the XML, i have set the column datatype to integer, and also set the column to allow dbnull. (dtColumn.AllowDBNull = True) I also tried to set the defaultvalue of the column to dbnull.value, but i still got the error.

Does anybody have a solution for this problem?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wil999

ASKER

Thank you for your reply.

I don't have a XML schema for this XML file. Sure, i could make one, but isn't there a way to do this without a XML schema? I do not understand why reading the XML into the table is a problem, because i told VB the datatype of the datatable column, and also that it should allow DBnull. (so it should know what to expect when reading the XML file)

I hope there is an other solution (without XML schema), but when not i have to live with it and created the schema.
You can try dataset.readxml and from the dataset get the data table, like dataset.tables(0),in this case column value shall come as empty string.
Avatar of Wil999

ASKER

Looks like it only working with a XML schema.
Thanks for your time!