Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to convert database tables into xml files

Reply
Thread Tools

how to convert database tables into xml files

 
 
Brahmam
Guest
Posts: n/a
 
      04-04-2006
when i click on import table in C#.net

we have to retrieve all the tables from the DB and those have to be
converted into xml files with their respected names

Can anyone give me the suggestions

Thanks in Advance
Brahmi


 
Reply With Quote
 
 
 
 
SStory
Guest
Posts: n/a
 
      04-04-2006
Once you have data in a dataset there is a method so save that straight to
XML; however it may not be in the format you want.

Shane
"Brahmam" <(E-Mail Removed)> wrote in message
news:Oa4rrV$(E-Mail Removed)...
> when i click on import table in C#.net
>
> we have to retrieve all the tables from the DB and those have to be
> converted into xml files with their respected names
>
> Can anyone give me the suggestions
>
> Thanks in Advance
> Brahmi
>
>



 
Reply With Quote
 
 
 
 
Jason Hales
Guest
Posts: n/a
 
      04-07-2006
Here's a little sample. You'll notice that I switch the
DataColumn.ColumnMapping so show writing out column as attributes and
also as elements (by default you don't get the schema written out)

using(DataSet myDataSet = new DataSet())
{

using(DataTable myDataTable = new DataTable("MyData"))
{
myDataSet.Tables.Add(myDataTable);
myDataTable.Columns.Add(new DataColumn("EmployeeID", typeof(Int32)));
myDataTable.Columns.Add(new DataColumn("EmployeeName",
typeof(string)));

DataRowCollection rows = myDataTable.Rows;

DataRow newRow = myDataTable.NewRow();
newRow["EmployeeID"] = 1;
newRow["EmployeeName"] = "Jason Hales";
rows.Add(newRow);

newRow = myDataTable.NewRow();
newRow["EmployeeID"] = 2;
newRow["EmployeeName"] = "Bob Smith";
rows.Add(newRow);

foreach(DataColumn column in myDataTable.Columns)
{
column.ColumnMapping = MappingType.Attribute;
}
myDataSet.WriteXml(@"c:\temp\data with attributes.xml");

foreach(DataColumn column in myDataTable.Columns)
{
column.ColumnMapping = MappingType.Element;
}
myDataSet.WriteXml(@"c:\temp\data with elements.xml");


}
}

Results in :
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<MyData EmployeeID="1" EmployeeName="Jason Hales" />
<MyData EmployeeID="2" EmployeeName="Bob Smith" />
</NewDataSet>

and:
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<MyData>
<EmployeeID>1</EmployeeID>
<EmployeeName>Jason Hales</EmployeeName>
</MyData>
<MyData>
<EmployeeID>2</EmployeeID>
<EmployeeName>Bob Smith</EmployeeName>
</MyData>
</NewDataSet>

 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      05-07-2006
If you use SQL Server, you can use FOR XML RAW or FOR XML AUTO in a
SELECT statement to get the result as XML.

Brahmam wrote:
> when i click on import table in C#.net
>
> we have to retrieve all the tables from the DB and those have to be
> converted into xml files with their respected names
>
> Can anyone give me the suggestions
>
> Thanks in Advance
> Brahmi
>
>

 
Reply With Quote
 
samu4uhere samu4uhere is offline
Junior Member
Join Date: Sep 2012
Posts: 1
 
      09-29-2012
Quote:
Originally Posted by Brahmam View Post
when i click on import table in C#.net

we have to retrieve all the tables from the DB and those have to be
converted into xml files with their respected names

Can anyone give me the suggestions

Thanks in Advance
Brahmi


Check this download link...
to convert SQL server Database table into XML...its an Application..

search in google like "createxmlfromdb"
 

Last edited by samu4uhere; 09-29-2012 at 12:22 PM.. Reason: updated link
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to convert ms sql 2008 tables to XML files? Eric S ASP .Net 11 06-17-2009 04:33 PM
Re: Is there a way to convert ms sql 2008 tables to XML files? Juan T. Llibre ASP .Net 0 06-12-2009 02:12 PM
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Convert database BRW files into DBF files ? geothermal Computer Support 3 03-28-2005 07:40 PM
Tools to extract data from SQL database and convert it into XML & insert XML data into SQL databases Harry Zoroc XML 1 07-12-2004 10:10 PM



Advertisments