Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Loading XML Document
I am trying to load an xml document that has the following format
I am trying to load this into SQL Server. I have a SPROC that can handle the loading, my problem is getting the XML document into the SQL Server SPROC.
I have done a lot of research and have read use a DataSet, etc... but need some help on the VB.net part of things... Any and all help would be appreciated.
8/22/2022 - Mon
here you go, will need to change the insert to cater for your specific table etc. also might want to put the code in a loop if you are inserting multiple files
Dim myReader As New System.IO.StreamReader("C:
Dim strXml As String = myReader.ReadToEnd()
Dim myConnection As New SqlConnection(strConnectio
Dim myCommand As New SqlCommand("Insert INTO XmlTable (xmlColumnName) Values (@xmlData)", myConnection)
please not that your xml example is not well formed and sql will throw an exception (closing tag should be </System> xml is case sensitive) also might be a good idea to create an xsd and assign it to the xml column which will check if the right elements are present in the xml when you insert it into the xml column
Wabbit... Looks good, still have a few questions
1) What is the parameter @xmlData?
2) Lets say I want to enter information into an Orders table that has both the Account (sysinfo) & Mark(order)?
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Good answer... had to make 1 small change
myCommand.CommandType = CommandType.StoredProcedur
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent