Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2006, 12:35 PM
Authorized User
 
Join Date: Apr 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Write Nested XML document into SQL Server tables

--------------------------------------------------------------------------------

Hello,

I have an xml document that I am pulling from a webservice through vb.net that has nested tables in it. I need to write each of these nested tables each to a separate Sql Server table using VB.NET.

I have the xml schema file of the webservice xml in my visual studio project, and I have had no problem writing previous xmls (writing children to a table that had a single parent, which is shown in my code below) to Sql Server with code I have written. The problem is I've never iterated through a nested xml before in vb.net and need help getting in the right direction (I have exhausted google and this forum trying to find an answer). I have done this with XPath in java before, but as I am new to vb.net, I'm a little unsure about the power of some of the classes.

For my write using xml documents with single parent-child data, here is a code snippet I've used (forgive any typos, I can't just copy and paste the source code bc it is on a confidential box, I have to type it out):

------------------------------
Dim counter As Integer
objDSXML = New Dataset
objDSDBTable = New DataSet("unit") //table in database is called 'unit'
ObjCmdBuilder = New SqlCommandBuilder

objDSXML.ReadXml(xmlFilePath)
objAdapter = New SqlDataAdapter("Select unitname, unittype from unit where 1=2, objSQLConn)
objAdapter.Fill(objDSDBTable)

For Each objDataRow In objDSXML.Tables(0).Rows
With ObjDSDBTable.Tables(0)

objDBRow = .NewRow()

For counter = 0 To numberOfColumns - 1
objDBRow(counter) = objDataRow(counter)
Next counter
.Rows.Add(objDBRow)

End With
Next

ObjCmdBuilder = New SqlCommandBuilder(objAdapter)
objAdapter.Update(objDSDTable,"unit")
------------------------------------

Using something similar to this, can someone show me code for a nested XML that can be iterated through and written to a database? If not, can someone show me a working example of how to do this?

Thanks in advance!! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Import a XML file into SQL Server tables Cha BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 April 1st, 2008 09:54 PM
XMl Document Reading in SQL Server shashideore SQL Server 2005 1 April 26th, 2007 07:16 AM
Write a XML Document using java. vinitpugaliya XML 0 January 8th, 2007 06:26 AM
how to write sql statement for nested subuery thas123 SQL Server 2000 3 February 23rd, 2006 02:37 PM
Write Conflict message with SQL Server tables mmcdonal Access 3 November 18th, 2004 11:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.