473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Reading XMLString into Typed Dataset

Hi

My program needs to insert records into a strongly typed dataset. The records are passed as a String.

So far I have:

Expand|Select|Wrap|Line Numbers
  1.     Private Sub InsertIntoCustomersTable(ByVal XMLString As String)
  2.  
  3.          Dim sr As New System.IO.StringReader(XMLString) 
  4.  
  5.         '  Read in the XMLString to populate the table
  6.         Mssqlds.Customer.ReadXml(sr)
  7.  
  8.         '  Update db
  9.         Me.CustomerTableAdapter.Update(Mssqlds.Customer)
  10.  
  11.     End Sub
This doesnt error but no rows are added to my Customer datatable. The columns are added but no data.

If I use an untyped dataset:

Expand|Select|Wrap|Line Numbers
  1.     Private Sub InsertIntoCustomersTable(ByVal XMLString As String)
  2.  
  3.         Dim ds As New DataSet              
  4.         Dim da As New MySqlDataAdapter
  5.         Dim sr As New System.IO.StringReader(XMLString)
  6.  
  7.         ' Set the data adapter statements
  8.         getCustomerDataset(ds, da)
  9.  
  10.         ds.ReadXml(sr, XmlReadMode.IgnoreSchema)
  11.  
  12.     End Sub
This loads the records into new rows of the Customer datatable.

How do I load XML stored as a string into a typed dataset datatable so I can call .update?

Thanks

Darren
Apr 5 '07 #1
1 1274
My XML that is contained in the XMLString variable looks like:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Customers>
  3.     <Customer>
  4.         <customer_id>2931</customer_id>
  5.         <email>my_name@domain.co.uk</email>        <password>ab8a754d78af898c0816282a0c34d53c</password>
  6.         <title>Mr</title>
  7.         <firstName>Darren</firstName>
  8.         <lastName>Rhymer</lastName>
  9.         <add_1>35 High Street</add_1>
  10.         <add_2/>
  11.         <town>Trowbridge</town>
  12.         <county>Wiltshire</county>
  13.         <zoneId>367</zoneId>
  14.         <postcode>BA14 5RTpostcode>
  15.         <country>225</country>
  16.         <phone>01234 555666</phone>
  17.         <mobile/>
  18.         <regTime>1175250521</regTime>
  19.         <ipAddress>88.23.23.121</ipAddress>
  20.         <noOrders>1</noOrders>
  21.         <optIn1st>0</optIn1st>
  22.         <htmlEmail>1</htmlEmail>
  23.         <type>1</type>
  24.     </Customer>
  25. </Customers>
Apr 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SS | last post by:
Is there any way by which i can read each node(with attribute and values) of an xml file as a string? Is there a way to get this using XmlTextReader.
5
by: Drew Yallop | last post by:
I read an XML file with a stream reader in VB.Net. When I look at the stream reader output in debug mode (by passing cursor over the stream reader object)the format is a perfect replica of the...
0
by: Earl Teigrob | last post by:
I would like to be able to validate an XML file before it is (or as it is being) read into a DataSet. I have a class that dynamically creates a DataSet with typed columns based on another...
3
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
1
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't...
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
4
by: sherifffruitfly | last post by:
Hi, I have an xml file with structured like this: <?xml version="1.0" encoding="UTF-8"?> <Soldiers> <Soldier name="Billy Smith" rank="Private" serial="34" /> (a bunch more soldiers)
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.