bulkcopy.writetoserver()
-
actully i want to copy the XML file into the database table, but in distination table there is an extra column. i want to add a new column and gave it a value. DataSet ds = new DataSet(); ds.ReadXml("C:\\abc.xml"); DataTable sourceData = new DataTable(); sourceData = ds.Tables[0]; DataColumn UID = new DataColumn(); UID.DataType = System.Type.GetType("System.Int32"); UID.ColumnName = "UID"; sourceData.Columns.Add(UID); sourceData.Columns["UID"] = 12; i have done the mapping.... bulkCopy.ColumnMappings.Add("UID", "UID"); . . . . and in end bulkCopy.DestinationTableName = "Contact"; bulkCopy.WriteToServer(sourceData); but UID column always gave the null value in database... any idea??
-
actully i want to copy the XML file into the database table, but in distination table there is an extra column. i want to add a new column and gave it a value. DataSet ds = new DataSet(); ds.ReadXml("C:\\abc.xml"); DataTable sourceData = new DataTable(); sourceData = ds.Tables[0]; DataColumn UID = new DataColumn(); UID.DataType = System.Type.GetType("System.Int32"); UID.ColumnName = "UID"; sourceData.Columns.Add(UID); sourceData.Columns["UID"] = 12; i have done the mapping.... bulkCopy.ColumnMappings.Add("UID", "UID"); . . . . and in end bulkCopy.DestinationTableName = "Contact"; bulkCopy.WriteToServer(sourceData); but UID column always gave the null value in database... any idea??