how to view XML data before importing into the database

Posted by rajrprk-12523 under ASP.NET on 12/1/2011 | Points: 10 | Views : 811 | Status : [Member] | Replies : 1
protected void btnimport_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TNVKP_8;Integrated Security=True");
DataSet reportData = new DataSet();
//reportData.ReadXml(Server.MapPath(FileUpload1.ToString()));
//reportData.ReadXml(Server.MapPath(FileUpload1.FileName.ToString()));
reportData.ReadXml(Server.MapPath(FileUpload1.FileName));
string filename = System.IO.Path.GetExtension(FileUpload1.FileName.ToString());
string filenames = System.IO.Path.GetFullPath(FileUpload1.FileName.ToString());
Response.Write(FileUpload1.FileName);
//reportData.ReadXml(Server.MapPath(filenames.ToString()));
SqlBulkCopy sbc = new SqlBulkCopy(con);
sbc.DestinationTableName = "employee";
sbc.ColumnMappings.Add("TALLY_REC_ID_CODE", "empid");
sbc.ColumnMappings.Add("CLUSTER_ID", "empname");

sbc.ColumnMappings.Add("UNIT_TYPE", "empaddress");
sbc.ColumnMappings.Add("VPRC_ID", "empcity");
sbc.ColumnMappings.Add("SHG_ID", "empstate");

sbc.ColumnMappings.Add("PIP_NO", "empzip");
sbc.ColumnMappings.Add("NAME_OF_THE_MEMBER", "emplic");
sbc.ColumnMappings.Add("TYPE_OF_LOAN", "empstatus");

sbc.ColumnMappings.Add("PRINCIPAL", "empp");
sbc.ColumnMappings.Add("INTEREST", "empi");
con.Open();
sbc.WriteToServer(reportData.Tables[0]);
con.Close();
lblmsg.Text = "Records inserted successfully";
}
the above coding i have used to import data into sql in c#
before going to import i want to view the xml data with the help of view button
so post solution for this
Thanks in advance




Responses

Posted by: Varung on: 12/3/2011 [Member] Starter | Points: 25

Up
0
Down
just write this code in view button click event

string xmlData=FileUpload1.FileContent;

G.Varun

rajrprk-12523, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response