I am using the following code to Bulk Insert a data table into my SQL Table:
// Set up the bulk copy object.
using (SqlBulkCopy bulkCopy =
new SqlBulkCopy(destinationConnection.Connection))
{
bulkCopy.DestinationTableName =
Constants.ReportDataTable;
// Write from the source to the destination.
DataTable dtBulk = GetDatatableInReportDataFormat(dt, objectName, version);
bulkCopy.WriteToServer(dtBulk);//To get the Datatable in the SQL table format
}
I have a column in my SQL Table named "Value", its type is decimal (28,5). My problem is that some values with decimal numbers are being automaticaly rounded, thus I am losing precison, for example a value of 0.72768
is being saved as 0.72767
.
In the Datatable, the column "Value" is of type Double.
Any body has an idea? Thank
Make the column in the DataTable
as decimal
rather than double
… I strongly suspect this will make the problem disappear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With