C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » XML »

Creating XML File from the database table.


Posted Date: 10 Aug 2009    Resource Type: Code Snippets    Category: XML
Author: satyaMember Level: Diamond    
Rating: 1 out of 5Points: 7



Creating XML file from the Database table




Description:


The below code is used to create a xml document from

the table of the database.






Code Behind:



SqlConnection con = new SqlConnection();
DataSet ds = new DataSet();

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindtoXml();
}
}


private void BindtoXml()
{
con.ConnectionString = "server=10.104.10.145;database=Northwind;user id=sa;password=sa";
SqlDataAdapter da = new SqlDataAdapter("Select * from customers", con);

da.Fill(ds, "customers");

if (ds.Tables["customers"].Rows.Count > 0)
{
ds.WriteXml("D:\\CustDataNewfile.Xml");
ds.WriteXmlSchema("D:\\CustDataNewfile.xsd");
Response.Write("Data Loaded in Xml File");
}
else
{
Response.Write("No data found in the table");
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Creating XML File from the database table.  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Simple XML Query with Linq
Previous Resource: Export to xml from listview Control.
Return to Discussion Resource Index
Post New Resource
Category: XML


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use