473,772 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with Importing XML data to a table

Using some VB sample code on the Internet I have the following
that works well and exports a set of records to an XML file:

Dim oCmd, sSQL, oDom

Set oDom = CreateObject("M sxml2.DOMDocume nt.4.0")

Set oCmd = CreateObject("A DODB.Command")
oCmd.ActiveConn ection = "Provider=SQLOL EDB;Data Source=(local); Initial
Catalog=TestXML ;UID=sa;Passwor d=123456"

sSQL = "<ROOT
xmlns:sql=""urn :schemas-microsoft-com:xml-sql""><sql:quer y>" & "select *
from tblTest for xml auto</sql:query></ROOT>"

oCmd.CommandTex t = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"

oCmd.Properties ("Output Stream") = oDom
oCmd.Execute , , 1024

oDom.Save "C:\temp\testdt s.xml"
This is my first day of using XML in SQL Server and I need help on how
to imitate INSERT statements by basically importing data from an xml file.

With some changes I managed to write VB code that seems to be reading
the XML file I exported earlier but I can't seem to know what to do to be
able to take the data only of the XML and INSERT it into a table.
The code I used is the one found in the SQL Online Help, search in INDEX
for "OPENXML" and then choose "USING OPENXML"

If you have sample code or can point me to a link that has sample code to
achieve what I want, I would appreciate your help.

Thank you

Jul 23 '05 #1
2 1365
Check this one out. This is pretty nifty.

http://www.codeproject.com/cs/databa...ic_OpenXml.asp

Jul 23 '05 #2
Cool Thanks, I will look at it.

Actually believe it or not I managed to make things happen when I read your
post about OPENXML and the City/State problem you were having.
I am currently using that code and so far so good.
I'll continue working and I will check the link also.

Thanks again.

"Bostonasia n" <ax****@gmail.c om> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Check this one out. This is pretty nifty.

http://www.codeproject.com/cs/databa...ic_OpenXml.asp

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7395
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
1
3216
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000 characters. When I import it into A2K, that field is truncated. If I try to inport the file into an EXISTING table that I define myself where that field is a MEMO field, the import crashes.
9
4035
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then need to input this in an Access database, where I do a comparison with the Actual cost. The table “TblBudget” in Access is made of 4 fields, namely: (1) CostElement (2) CostCenter (3) Month (4) Amount$. At the moment this method is very cumbersome....
2
3928
by: kuhni | last post by:
Hi everybody, I am totally desperate because I cannot solve a really simple problem: I have a specific text-file which I want to import into an existing database. The problem is that the columns have different names so I receive an error message when importing via the "Get External Data"-Wizard. The second problem is that this text file includes several rows without any relevant data, only symbols like "-----" in the various columns. I...
3
1728
by: pemigh | last post by:
A while back I imported tables to a new database via Files-->Get External Data --> Import... All was well for several months, and then the database started behaving badly in a couple of ways, including slow (actually speed was fine when users opened database, then deteriorated after a few minutes of normal use) and errors when trying to enter data. Specifically, this appears when entering data in a subform, even when an individual is...
1
4656
by: winzy | last post by:
I have a table in Access which needs updating from an Excel file. Instead of importing the whole Excel like a new table in Acess, how do I do a partial import/update?? For example, Access table has 100 rows of records and 10 columns of attributes. The Excel table has only 50 rows of records and and 2 attributes. The key IDs for the 50 rows and names for the 2 attributes are already defined in the Access table. Thanks in advance!!
0
1487
by: Mike Collins | last post by:
I am importing a XML file and have not been having the best of luck in doing this, but I do have the following solution below. I will not be importing more than 2000 records at a time, but will be importing data to many different tables. Can someone explain if there is a better way to do what I am doing without having to call a stored procedure for each row (like I'm doing below)? A good example would be great as my understanding of xml or...
2
2115
by: Mike Collins | last post by:
I am importing a XML file and have not been having the best of luck in doing this, but I do have the following solution below. I will not be importing more than 2000 records at a time, but will be importing data to many different tables. Can someone explain if there is a better way to do what I am doing without having to call a stored procedure for each row (like I'm doing below)? A good example would be great as my understanding of xml or...
3
3354
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and appending second file in last of the access table created earlier by importing data. thanks .plz help me.
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.