Solved

Dataset to XML

Posted on 2006-06-14
4
441 Views
Last Modified: 2010-04-23
Hello Experts,

I'm working on my first VS 2005 app in VB, and having some difficulity.

It is a mobile app I'm writing for Time keeping on the road.  It simply has a couple buttons where I clock in or out.  I want to save the data in an xml file.

I've created a Dataset in VS and it stored an xsd file in the solution which has the Datatable in it.

I don't know how to instigate or start the dataset to store data back to the xml file.  I'm used to loading data from sql or access.  But here it's just write to xml with each button click.  Should be easy....Right

Thanks


0
Comment
Question by:Jimmy Lea
[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
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 250 total points
ID: 16908794
Private Sub WriteXmlToFile(thisDataSet As DataSet)
    If thisDataSet Is Nothing Then
        Return
    End If ' Create a file name to write to.
    Dim filename As String = "myXmlDoc.xml"
    ' Create the FileStream to write with.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)
    ' Write to the file with the WriteXml method.
    thisDataSet.WriteXml(myFileStream)
End Sub

or
 SqlConnection1.Open()

        SqlDataAdapter1.Fill(Dataset11, "Account")
        Dataset11.WriteXml("d:\\test.xml")
--pradeep
0
 
LVL 18

Assisted Solution

by:vbturbo
vbturbo earned 250 total points
ID: 16910688
Hi

try this

Imports System
Imports System.Xml
Imports System.Data
Imports System.IO
 
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim ds As New DataSet
        ' check if previous file exists then delete it
        If File.Exists("c:\xmlfile.xml") = True Then
            File.Delete("c:\xmlfile.xml")
        End If

        ds.WriteXml("c:\xmlfile.xml")

    End Sub

hope this helps
rgds vbturbo
0
 

Author Comment

by:Jimmy Lea
ID: 16917358
I understand how to write the xml file once the dataset has some data in it.  How do I start the dataset?  Can I use the dataset that I built with VS?
0
 

Author Comment

by:Jimmy Lea
ID: 16917684
I got it.  It just took me a little bit to figure out how to place a dataset in a fom with the new VS 2005.  Thanks
Jim
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 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