473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SQL to well formatted XML file via .NET

I am trying to create several .xml files, mirrored from my SQL database that
are shaped according to an XSD schema. However, I have hit a brick wall!
Droving through several materials on how to perform this function has
resulted in some slightly jarring results!
Basically, I would like to create a dataset.xsd XML map of a stored
procedure from the SQL database, and through use of this .xsd pass the
resulting correctly formatted .xml to a file (or heck even the /bin!)
Here is a code that I have been working with to take the stored procedure
view and pass it to an .xml file - to the /bin. But the dataset.xsd file does
not effect the result, nor return the correct schema using "WriteSchema".
I must be missing something crucial...

CODE
CODE:
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml

Module Module 1

Sub Main()
Dim objConn As New SqlConnection("Server=...;Database=....;Integrated
Security=....")
objConn. Open()
Dim objCmd As New SqlCommand("MyProcedure", objConn)
objCmd.CommandType = CommandType.StoredProcedure
Dim objAdpt As New SqlDataAadapter (objCmd)
Dim objDs As New DataSet ("MyDataset")
objAdpt.Fill (objDs, "Catalog")
Dim objFile As New FileStream("Catalog.xml", FileMode.Create)
Dim objSWriter As New StreamWriter(objFile)
objDs.WriteXml(objSWriter.XmlWriteMode.WriteSchema )
objSWriter.Close()
objFile.Close()
objConn.Close()

End Sub
End Module

I hope someone can point me in the right direction here...
Thanks -
Benjatado
Nov 12 '05 #1
2 1037
Benjatado wrote:
I am trying to create several .xml files, mirrored from my SQL database that
are shaped according to an XSD schema. However, I have hit a brick wall!
Droving through several materials on how to perform this function has
resulted in some slightly jarring results!
Basically, I would like to create a dataset.xsd XML map of a stored
procedure from the SQL database, and through use of this .xsd pass the
resulting correctly formatted .xml to a file (or heck even the /bin!)
Here is a code that I have been working with to take the stored procedure
view and pass it to an .xml file - to the /bin. But the dataset.xsd file does
not effect the result, nor return the correct schema using "WriteSchema".
I must be missing something crucial...

CODE
CODE:
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml

Module Module 1

Sub Main()
Dim objConn As New SqlConnection("Server=...;Database=....;Integrated
Security=....")
objConn. Open()
Dim objCmd As New SqlCommand("MyProcedure", objConn)
objCmd.CommandType = CommandType.StoredProcedure
Dim objAdpt As New SqlDataAadapter (objCmd)
Dim objDs As New DataSet ("MyDataset")
objAdpt.Fill (objDs, "Catalog")
Dim objFile As New FileStream("Catalog.xml", FileMode.Create)
Dim objSWriter As New StreamWriter(objFile)
objDs.WriteXml(objSWriter.XmlWriteMode.WriteSchema )
objSWriter.Close()
objFile.Close()
objConn.Close()

End Sub
End Module

I hope someone can point me in the right direction here...
Thanks -
Benjatado

Why not just use objDs.writexmlschema?
Nov 12 '05 #2
"Clamps" wrote:
Why not just use objDs.writexmlschema?


Would that write the XML document based upon the XSD with the
sql:relationship tags? Or would it write out the schema only?
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Craig Petrie | last post by:
Hi, I have a large table in Word 2003 that has formatted text in the cells and wish to read and convert a cells formatted contents to html output via vb.net code. The formatting contains the...
6
by: mesterak | last post by:
I have some log files I need to process via VB.NET and C# based applications. I read the entire contents of each file individually into a string variable using the StreamReader class (.ReadToEnd). ...
6
by: bfowlkes | last post by:
Hello, I am trying to parse two pre-formatted text files and write them to a different files formatted in a different way. The story about this is I was hired along with about 20 other people...
3
by: sonu | last post by:
I am getting some data 'strData' from database through reader object. The data 'strData' is sent to a doc using FilesystemObject line by line in doc file located on a specific location. 1.Code...
7
by: pkirk25 | last post by:
My data is in a big file that I have no control over. Sometimes its over 30 MB and often there are several of them. It is machine generated and is nicely formatted. Example text follows: ...
1
by: EricBlair | last post by:
Hello, Wondering if someone might help on this... I write out formatted text to a file then load it into a RichTextBox. However the text that is formatted into a table displays like this...
3
by: Bjarne Nielsen | last post by:
Hi all In my C# program I need to read a file, which is exported from a DOS program. So words such as "Afløser" (with special danish characters) is read like "Afl�ser". How do I...
0
by: satarupa | last post by:
I want to read the formatted (bold,underline,italics) text of a word dcoument using c# i can read the document even the paragraphn in it but not the formatted text plzz help following is the...
2
by: Sandhya L. Gite | last post by:
Hi Everybody I m generating dynamic rss using php I have attached the CSS to it and i can see well formatted ..rss file in Mozila Firefox browser But If i request the same file in Internet...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.