Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.Net - Save DataTable from a Dataset To XML

Posted on 2004-09-02
8
Medium Priority
?
463 Views
Last Modified: 2012-05-05
I want to save Only the datatable ( RamTable ) to xml

i need both read and write functions please.
0
Comment
Question by:Vartana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11968012
DataSet.WriteXML(path) and DataSet.ReadXML(path)

Bob
0
 
LVL 1

Author Comment

by:Vartana
ID: 11968027
I DOnt want to save all the datatables in the dataset
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11968070
How many tables does the dataset have?

Bob
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:thenrich
ID: 11968227
Create a new dataset with only the table you want then do what Bob suggested above.

'DataSet.WriteXML(path) and DataSet.ReadXML(path)

Bob'
0
 
LVL 1

Author Comment

by:Vartana
ID: 11968242
more then 1
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 2000 total points
ID: 11969208
Hi there... try this..

    Sub WriteTableDataToXML(ByVal DS As DataSet, ByVal TableIndex As Int32, ByVal FileName As String)
        Dim TempDS As New DataSet
        TempDS.Tables.Add(DS.Tables(TableIndex))
        TempDS.WriteXml(FileName)
    End Sub

call it as , WriteTableDataToXML([DataSet Name],[0-based index of the table in dataset],[.xml file name to store in double quotes])

Make similar approach for reading too...
-Baan
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11969231
oops... there was, little problem with the code...
it is fixed now...

    Sub WriteTableDataToXML(ByVal DS1 As DataSet, ByVal TableIndex As Int32, ByVal FileName As String)
        Dim TempDS As New DataSet
        Dim DT As New DataTable
        DT = DS1.Tables(TableIndex).Copy
        TempDS.Tables.Add(DT)
        TempDS.WriteXml(FileName)
    End Sub

-Baan
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11969273
To read...

     Sub ReadTableDataFromXML(ByVal DS1 As DataSet, ByVal TableIndex As Int32, ByVal FileName As String)
        Dim TempDS As New DataSet
        TempDS.ReadXml(FileName)
        Dim DT As New DataTable
        DT = TempDS.Tables(TableIndex).Copy
        DS1.Tables.Add(DT)
    End Sub
call it as... ReadTableDataFromXML([Receiving DataSet Name],[0-based index of the table in XML file],[.xml file name to read from in double quotes])

-Baan
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question