Solved

Dataset to XML

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Setting location of a form 4 22
Form design in vb.net 7 19
Change data in datatable 8 16
Get String split 5 33
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

17 Experts available now in Live!

Get 1:1 Help Now