private void button1_Click(object sender, EventArgs e)
{
string cs = @"Server=SQLEX\WS19;Database=XML;User Id=sa;Password=;";
using (SqlConnection con = new SqlConnection(cs))
{
DataSet ds = new DataSet();
ds.ReadXml(@"E:\XML\product.xml");
DataTable dt1 = ds.Tables["cats"];
con.Open();
using (SqlBulkCopy bc = new SqlBulkCopy(con))
{
bc.DestinationTableName = "Category";
bc.ColumnMappings.Add("catClass", "types");
bc.ColumnMappings.Add("catDefinition", "description");
bc.ColumnMappings.Add("cattValue", "amount");
bc.WriteToServer(dt1);
}
}
}