Hello, I am trying to import an XML document into SQL Server. I have tried
DTS, bulk loading into SQL server and anything else I can think of...
The only thing that has worked slightly is :
Dim objSQLConn As New SqlConnection(Constants.ConnectionString)
Dim objAdapter As SqlDataAdapter
Dim objDataRow, objDBRow As DataRow
Dim objDSXML As New DataSet()
Dim child As Xml.XmlNode
Dim objDSDBTable As New DataSet("tblStandardstest")
Dim ObjCmdBuilder As SqlCommandBuilder
objDSXML.ReadXml("c:/inetpub/wwwroot/olpt7/ACH_STATE_SUBJECT_Ohio_2001_Engli
sh.xml")
objSQLConn.Open()
objAdapter = New SqlDataAdapter("SELECT Benchmark, Grade,RefNum FROM
Standards", objSQLConn)objAdapter.Fill(objDSDBTable, "tblStandardstest")
For Each objDataRow In objDSXML.Tables("ACH_BENCHMARK").Rows
With objDSDBTable.Tables(0)
objDBRow = .NewRow()
objDBRow(0) = objDataRow("ACH_BENCHMARK_TEXT")
objDBRow(1) = objDataRow("ACH_GRADE_RANGE")
objDBRow(2) = objDataRow("ACH_STATE_REF_NUM")
.Rows.Add(objDBRow)
End With
ObjCmdBuilder = New SqlCommandBuilder(objAdapter)
objAdapter.Update(objDSDBTable, "tblstandardstest")
Next
objSQLConn.Close()
This only gets the one level. I need all levels to be placed in a SQL Server
Database in relational tables. Please help me!!!!!!!!!!!!!!!!!!!!!!
**********************SCHEMA****************************
<?xml version="1.0" encoding="utf-8"?>
<!--This file is auto-generated by the XML Schema Designer. It holds layout
information for components on the designer surface.-->
<XSDDesignerLayout layoutVersion="1" viewPortLeft="-10553"
viewPortTop="3344">
<ACH_STATE_SUBJECT_XmlElement left="-1561" top="450" width="15557"
height="3863" selected="0" zOrder="1" index="0">
<ACH_BENCHMARK_XmlElement left="-688" top="5583" width="13811" height="2963"
selected="0" zOrder="2" index="5">
<ACH_HEADERS_XmlElement left="-9553" top="9816" width="5292" height="2963"
selected="0" zOrder="5" index="4" />
<ACH_COMPENDIX_ALIGNMENT_XmlElement left="3466" top="9816" width="12065"
height="2963" selected="0" zOrder="7" index="5">
<ACH_COMPENDIX_SUBJ_XmlElement left="-2991" top="14049" width="5292"
height="2963" selected="0" zOrder="9" index="0" />
<ACH_COMPENDIX_TRIPLET_XmlElement left="3571" top="14049" width="5292"
height="2963" selected="0" zOrder="11" index="1" />
<ACH_COMPENDIX_VOCAB_XmlElement left="13414" top="14049" width="5292"
height="2963" selected="0" zOrder="13" index="2">
<ACH_COMPENDIX_VOCAB_LETTER_XmlElement left="10133" top="18282" width="5292"
height="2963" selected="0" zOrder="15" index="0" />
<ACH_COMPENDIX_VOCAB_WORD_XmlElement left="16695" top="18282" width="5292"
height="2963" selected="0" zOrder="17" index="1" />
</ACH_COMPENDIX_VOCAB_XmlElement>
</ACH_COMPENDIX_ALIGNMENT_XmlElement>
</ACH_BENCHMARK_XmlElement>
</ACH_STATE_SUBJECT_XmlElement>
<NewDataSet_XmlElement left="33445" top="635" width="5292" height="2963"
selected="0" zOrder="19" index="1">
<ref_x003D_ACH_STATE_SUBJECT_XmlElement left="33445" top="4868" width="5292"
height="2963" selected="0" zOrder="20" index="0">
<ACH_BENCHMARK_XmlElement left="33445" top="9101" width="5292" height="2963"
selected="0" zOrder="22" index="5">
<ACH_HEADERS_XmlElement left="20321" top="13334" width="5292" height="2963"
selected="0" zOrder="24" index="4" />
<ACH_COMPENDIX_ALIGNMENT_XmlElement left="36726" top="13334" width="5292"
height="2963" selected="0" zOrder="26" index="5">
<ACH_COMPENDIX_SUBJ_XmlElement left="26883" top="17567" width="5292"
height="2963" selected="0" zOrder="28" index="0" />
<ACH_COMPENDIX_TRIPLET_XmlElement left="33445" top="17567" width="5292"
height="2963" selected="0" zOrder="30" index="1" />
<ACH_COMPENDIX_VOCAB_XmlElement left="43288" top="17567" width="5292"
height="2963" selected="0" zOrder="32" index="2">
<ACH_COMPENDIX_VOCAB_LETTER_XmlElement left="40007" top="21800" width="5292"
height="2963" selected="0" zOrder="34" index="0" />
<ACH_COMPENDIX_VOCAB_WORD_XmlElement left="46569" top="21800" width="5292"
height="2963" selected="0" zOrder="36" index="1" />
</ACH_COMPENDIX_VOCAB_XmlElement>
</ACH_COMPENDIX_ALIGNMENT_XmlElement>
</ACH_BENCHMARK_XmlElement>
</ref_x003D_ACH_STATE_SUBJECT_XmlElement>
</NewDataSet_XmlElement>
</XSDDesignerLayout>
*************************************END SCHEMA************************
Christoph Schittko [MVP] - 02 Jul 2003 05:47 GMT
Christine,
Take a look at SQLXML [0]. You can import the XML data either via
Updategrams or via Bulkload (available through COM interop)
I hope this link is getting you started. Feel free to come back once you
have more questions.

Signature
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
[0]
http://msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28001300
> Hello, I am trying to import an XML document into SQL Server. I have tried
> DTS, bulk loading into SQL server and anything else I can think of...
[quoted text clipped - 13 lines]
>
> Dim ObjCmdBuilder As SqlCommandBuilder
objDSXML.ReadXml("c:/inetpub/wwwroot/olpt7/ACH_STATE_SUBJECT_Ohio_2001_Engli
> sh.xml")
>
[quoted text clipped - 118 lines]
>
> *************************************END SCHEMA************************