private void xm_file()
{
DataSet ds = get_DataSet();
ds.WriteXml(@"C:\adi.xml");
}
private DataSet get_DataSet()
{
DataSet ds = new DataSet("DB");
ds.Namespace = "studentdetails";
DataTable stdTable = new DataTable("Student");
DataColumn col1 = new DataColumn("Name");
DataColumn col2 = new DataColumn("Address");
stdTable.Columns.Add(col1);
stdTable.Columns.Add(col2);
ds.Tables.Add(stdTable);
//Add student Data to the table
DataRow newRow; newRow = stdTable.NewRow();
newRow["Name"] = "Jc Adinarayana reddy";
newRow["Address"] = "Anantapur";
stdTable.Rows.Add(newRow);
newRow = stdTable.NewRow();
newRow["Name"] = "Jc Pavan";
newRow["Address"] = "Tadipatri";
stdTable.Rows.Add(newRow);
newRow = stdTable.NewRow();
newRow["Name"] = "Raja";
newRow["Address"] = "Anantapur";
stdTable.Rows.Add(newRow);
ds.AcceptChanges();
return ds;
}
No comments:
Post a Comment