Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Updating an Access database using an XML document ...

Posted on 2005-03-23
Medium Priority
Last Modified: 2010-04-16

I am relatively new to XML so the question should be easy enough.

Given an XML document that has all the tags defined for a corresponding table in Access, how do you UPDATE the database with the data contained in the XML document.

I have been able to ADD a row (for when the primary key data doesn't exist in the database), but how do you UPDATE????


Question by:srigby22
  • 2
LVL 10

Expert Comment

ID: 13610717
you would need to have a specific column that was the ID of the column to update, for example

    <name>new name</name>
    <name>new name again</name>

you would then need to use XPath to select your nodes and exeute SQL based on the value, for example

sql_string = "UPDATE table SET name = '" + name + "' WHERE id = " + id

you could get cleaver and make this generic, for example

    <name>new name</name>
    <id id='yes'>123</id>
    <name>new name again</name>
    <id id='yes'>321</id>

now you could build the query dynamically and use the fact that the ID entry is marked as id to know this is the where clause. the node names would be the same as the column names in the database

LVL 10

Accepted Solution

makerp earned 400 total points
ID: 13610732
XPathNavigator _navigator = (new XPathDocument(new FileStream("myfile.xml",FileMode.Open))).CreateNavigator();
XPathNodeIterator _iterator = _navigator.Select("/items/item");
   // use the _iterators members to ge the node values and build the sql query

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question