Solved

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

Posted on 2015-02-08
6
58 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
[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
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
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

695 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