why is there an exception when I call the ReadXml() method on a DataTable object?

This is a discussion on why is there an exception when I call the ReadXml() method on a DataTable object? within the C# Programming forums, part of the General Programming Boards category; I grabbed some data from a computer in the local network and placed it inside an ADO.NET DataTable and saved ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    3

    why is there an exception when I call the ReadXml() method on a DataTable object?

    I grabbed some data from a computer in the local network and placed it inside an ADO.NET DataTable and saved it to an Xml file in the local computer by calling the XmlWrite() method on the object and specifying XmlWriteMode.WriteSchema as the second argument.

    The Xml file was saved successfully, but when I later tried to open the same Xml file using the XmlRead() method, I kept getting an exception indicating that the data could not be read, apparently because the format of the data was not recognizable, or something along those lines.

    I reviewed the Xml file and didn't find any weird unicode characters in there. I also tried to write the Xml file by passing a FileStream object to the XmlWrite method and specifying the Encoding but that didn't solve the problem when i later tried to have the DataTable read the Xml file.

    Could this problem be related to the fact that the data that was loaded onto the first DataTable came from a spreadsheet file sitting on a computer running a 32 bit operating system, but when I tried to read the Xml file (after I saved it on the local computer via XmlWrite()) the data had been somehow made illegible by the fact that the local computer is running windows 7 64 bit?

    Someone mentioned something about a byte mark or something like that. Does anyone have a clue?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    > Someone mentioned something about a byte mark or something like that. Does anyone have a clue?

    Go and read this
    How To Ask Questions The Smart Way

    Then come back with actual code and information, and not just some ramble full of "apparently" and "something" and other vague and useless nonsense.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    3
    There is no need to post code because my explanation is sufficiently clear. If you are dyslexic and can't read that's a pity but it doesn't give you the right to be rude to people who have not crossed you in any way.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    What is the exception message? Normally when the Xml reader fails to read a document it will tell you where it failed eg. (3, 4) meaning column 3, row 4.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    41
    Quote Originally Posted by IComparer View Post
    The Xml file was saved successfully, but when I later tried to open the same Xml file using the XmlRead() method, I kept getting an exception indicating that the data could not be read, apparently because the format of the data was not recognizable, or something along those lines.
    This is vague, what, exactly, was the exception you received? What object threw the exception? How did you go about reading the XML? Did you bother to read the post on how to ask questions?

    Without knowing these things it's impossible to give an answer that would be meaningful.

    Could this problem be related to the fact that the data that was loaded onto the first DataTable came from a spreadsheet file sitting on a computer running a 32 bit operating system, but when I tried to read the Xml file (after I saved it on the local computer via XmlWrite()) the data had been somehow made illegible by the fact that the local computer is running windows 7 64 bit?
    No

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. method call error
    By DaleZ in forum C# Programming
    Replies: 2
    Last Post: 11-19-2010, 07:46 AM
  2. call a method from another to a class
    By vipur in forum Tech Board
    Replies: 7
    Last Post: 11-15-2009, 07:39 AM
  3. life cycle of exception object
    By George2 in forum C++ Programming
    Replies: 43
    Last Post: 02-13-2008, 06:50 AM
  4. exception handling, function call and memory
    By George2 in forum C++ Programming
    Replies: 21
    Last Post: 01-30-2008, 07:00 AM
  5. call static method
    By geeoff in forum C++ Programming
    Replies: 1
    Last Post: 02-01-2002, 01:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21