Avatar of Wil999
Wil999Flag for Netherlands asked on

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


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?

Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon
Karrtik Iyer

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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.
Karrtik Iyer

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.

Looks like it only working with a XML schema.
Thanks for your time!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.