Solved

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

Posted on 2015-02-08
6
50 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

14 Experts available now in Live!

Get 1:1 Help Now