Create data.xml from a dataset

Feb 19, 2008 at 7:54 PM
Edited Feb 20, 2008 at 1:24 PM
Hello, very nice slideshow. It would be a lot better if you could create the data.xml from a dataset. If anyone knows how to do this could you fill me and the rest of us in on the method. I've started to make this but am having issues getting the data formatted correctly in the data.xml. This task shouldn't be too hard for you veterans out there...
Feb 20, 2008 at 9:50 AM
Take a look at http://www.codeplex.com/SSDirDataProvWS. Makes it from two data tables.
Feb 20, 2008 at 1:26 PM
Edited Feb 22, 2008 at 9:40 PM
Ok, this is how I got slide.show to work from a dataset while creating the data.xml on the fly:

Try
Dim objConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("TESTConnectionString").ToString)

Dim objDS As New DataSet
objDS.DataSetName = "data"

Dim objaCmd As SqlCommand = New SqlCommand("Get_Albums", objConn)
objaCmd.CommandType = CommandType.StoredProcedure
Dim objaDA As New SqlDataAdapter(objaCmd)

objConn.Open()

objaDA.Fill(objDS, "album")

Dim objsCmd As SqlCommand = New SqlCommand("Get_Slides", objConn)
objsCmd.CommandType = CommandType.StoredProcedure
Dim objsDA As New SqlDataAdapter(objsCmd)

objsDA.Fill(objDS, "slide")

objConn.Close()

Dim primarykey As DataColumn = objDS.Tables("album").Columns("albumiD")
Dim foreignkey As DataColumn = objDS.Tables("slide").Columns("albumiD")

Dim relation As DataRelation = objDS.Relations.Add(primarykey, foreignkey)
relation.Nested = True

Dim album As DataColumn
For Each album In objDS.Tables("album").Columns
album.ColumnMapping = MappingType.Attribute
Next

Dim slide As DataColumn
For Each slide In objDS.Tables("slide").Columns
slide.ColumnMapping = MappingType.Attribute
Next

objDS.WriteXml(Server.MapPath("data.xml"), XmlWriteMode.IgnoreSchema)

Catch ex As SqlException
lblErrorMessage.Text = ex.ToString()
End Try

***************************Tables and SPROCs*********************

table: album
albumId, title, description, image

table: slide
slideId, albumId, title, description, image, thumbnail

stored procedure: Get_Albums
SELECT albumid, title, description, image FROM album

stored procedure: Get_Slides
SELECT slideId, albumId, title, description, image, thumbnail FROM slide
Feb 20, 2008 at 1:32 PM
Edited Feb 22, 2008 at 9:41 PM


boryto wrote:
Take a look at http://www.codeplex.com/SSDirDataProvWS. Makes it from two data tables.


Yes, this works great as well. Unfortunatly some hosting providers charge extra to make a folder set as an application in IIS. Creating from the dataset works well with out this requirement.