Solved

Dataset to XML

Posted on 2006-06-14
4
439 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 55
Help with preventing downloading a zip file 10 49
RLDC Reporting in Visual studio 11 43
VB.Net Data Class 1 20
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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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