public bool SqlBulkCopyByDatatable(DataTable dt,ref string emsg) { try { SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(SqlHelper.connStr, SqlBulkCopyOptions.UseInternalTransaction); sqlbulkcopy.DestinationTableName = dt.TableName; foreach (DataColumn dc in dt.Columns) { sqlbulkcopy.ColumnMappings.Add(dc.ColumnName, dc.ColumnName); } sqlbulkcopy.WriteToServer(dt); return true; } catch (Exception ex) { emsg = ex.ToString(); return false; } }