We help IT Professionals succeed at work.

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

Wil999 asked
Last Modified: 2016-02-02

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?

Watch Question

Software Architect
This one is on us!
(Get your first solution completely free - no credit card required)


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 IyerSoftware Architect

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!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.