Rajkumar R

Rajkumar R

  • NA
  • 183
  • 220k

How to view XML data before importing into the database

Dec 1 2011 12:37 AM
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



Answers (3)