Solved

VB.Net - Save DataTable from a Dataset To XML

Posted on 2004-09-02
8
450 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

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

Accepted Solution

by:
DotNetLover_Baan earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now