Converting Dataset To Xml File Using Asp.Net
01:54Introduction:
Here i will Explain How to convert Dataset To XML File using asp.net
C# Code:
1.Open New Website in VS and Add WebForm To Website
2.In .cs file add below name spaces
using System.Data;
using System.Data.SqlClient;
3.Add Below code to page load()
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con=new SqlConnection("Server=Administrator00;database=Acadamics;uid=ACMCPRJ;pwd=projects");
SqlDataAdapter da = new SqlDataAdapter("select * from Project_Primary", con);
DataSet ds = new DataSet();
da.Fill(ds);
ds.WriteXml("D:/Book2.xml");
Response.Write("Successfully stored In Xml file");
}
4.Run your application(Press F5)
OutPut:
Successfully stored In Xml file
Then Open Book2.xml in D Drive It shows like below
<?xml version="1.0" standalone="yes"
?>
- <NewDataSet>
- <Table>
<c_Project_Primary_Sno>9</c_Project_Primary_Sno>
<c_Project_Primary_Code>321312</c_Project_Primary_Code>
<c_Project_Primary_Name>fdgg</c_Project_Primary_Name>
<c_Project_Primary_Spcification>dfgfdg</c_Project_Primary_Spcification>
<c_Project_Primary_Description>fdgfdgd</c_Project_Primary_Description>
<c_Project_Primary_DeveloperName>fdgfdgg</c_Project_Primary_DeveloperName>
<c_Project_Primary_StartingDate>2009-09-16T00:00:00+05:30</c_Project_Primary_StartingDate>
<c_Project_Primary_EndingDate>2009-09-25T00:00:00+05:30</c_Project_Primary_EndingDate>
<c_Project_Primary_CompletedDate>2009-09-23T00:00:00+05:30</c_Project_Primary_CompletedDate>
<c_Project_Primary_RegistationDate>2009-09-22T05:12:43.047+05:30</c_Project_Primary_RegistationDate>
</Table>
- <Table>
<c_Project_Primary_Sno>4</c_Project_Primary_Sno>
<c_Project_Primary_Code>34532532</c_Project_Primary_Code>
<c_Project_Primary_Name>gryry</c_Project_Primary_Name>
<c_Project_Primary_Spcification>hgfhgfh</c_Project_Primary_Spcification>
<c_Project_Primary_Description>hggfhfh</c_Project_Primary_Description>
<c_Project_Primary_DeveloperName>gfhfghh</c_Project_Primary_DeveloperName>
<c_Project_Primary_StartingDate>2009-09-02T00:00:00+05:30</c_Project_Primary_StartingDate>
<c_Project_Primary_EndingDate>2009-09-24T00:00:00+05:30</c_Project_Primary_EndingDate>
<c_Project_Primary_CompletedDate>2009-09-23T00:00:00+05:30</c_Project_Primary_CompletedDate>
<c_Project_Primary_RegistationDate>2009-09-22T00:34:31.97+05:30</c_Project_Primary_RegistationDate>
</Table>
</NewDataSet>
0 comments :