Solved

Dataset to XML

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
Web Form VB.Net  import CSV 4 43
No Data for DropDown List 2 28
vb.net and creating a class 5 20
Convert Ctime to date time in textfile? 7 31
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of convertingā€¦
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ā€¦

839 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