Solved

Help with with exporting data from Datatable to xml using VB.NET

Posted on 2015-02-08
6
54 Views
Last Modified: 2015-02-12
Hi,

How do I modify the code below to export the data from the data table XML?

        Dim GGB As String
        GGB = "'" & ComboBox2.SelectedItem & "'"
        Dim SearchCriteriaZ As String = "COUNTRY IN (" & GGB & ")"
        xmlPath1 = System.IO.Path.Combine(Application.StartupPath + "\AOP40.xml")  'grid1
        dtsetcol1.Clear()
        dtsetcol1.ReadXml(xmlPath1)
        Dim FilteredDTA As DataTable
        Dim DVA As New DataView(dtsetcol1.Tables(0), SearchCriteriaZ, Nothing, DataViewRowState.CurrentRows)
        DVA.Sort = "SN"
        FilteredDTA = DVA.ToTable
        Me.C1Screen1.DataSource = FilteredDTA
     

Open in new window


Thanks,

Victor
0
Comment
Question by:vcharles
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Shane Kahkola
ID: 40597359
Try This:
FilteredDTA.WriteXML(Application.StartupPath + "\AOP40.xml")

Open in new window

0
 

Author Comment

by:vcharles
ID: 40597407
Hi,
I tried it but it didn't  work. Seem to work from a dataset but not a table, is there away to convert the data table to a dataset to use the code.
Victor
0
 
LVL 3

Accepted Solution

by:
Shane Kahkola earned 500 total points
ID: 40597411
Dim ds As New Dataset()
ds.Tables.Add(datatable)

Open in new window

0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 40
ID: 40599206
Are you still programming for framework 1.0 or 1.1

WriteXML was not supported on a DataTable in these versions, but has been since 2.0 (Visual Studio 2005).

If you are still on an old version, do yourself a favor and move to a newer version of Visual Studio and the framework. You can have the Express version for free if you program only from time to time, but if you are a professional and work in a group of 5 programmers or less, you can get the Community Edition, that is a free edition of the Professional.
0
 

Author Comment

by:vcharles
ID: 40606286
Hi, I'm using Framework 4.0, code from previous post works.

Thanks.
0
 

Author Closing Comment

by:vcharles
ID: 40606287
Thank You.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

827 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