?
Solved

Dataset to XML

Posted on 2006-06-14
4
Medium Priority
?
448 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
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

840 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