This is a bit of a brain teaser for me. We use a remote server to store our data. I have no control over naming convention or how data is stored in there. There is an sproc we have written on that server to call values from a table there. One of the values, price, comes back as 6.52....for this particular example.
The problem was when I then called that value after it was stored in our own local database it showed as 6.51.
Thinking it was something to do with rounding, and that it wasn't happening as the data transitioned through my c# program, I pulled a datatable that only retrieved the row in question from the remote server where that value existed(C# method code at end of this message). When I then did a console writeline to show me the value it said it was 6.52. At this point I was happy because obviously it was pulling the right value and it must be getting changed on our local server as it is entered.
At the same time I had changed the number of decimal places for that column in our local server from 2 to 4. When I retrieved that record it showed the value as 6.5199. So at least I am getting the right value. My question is though why would the console writeline be displaying a rounded number? My assumption would be that it would show the value as it is stored not round it?
Does anyone know what is going on here?
C# Method:
public void getSupplierMasterPriceTEST()
{
DataTable priceTable = new DataTable();
string queryString = "{call sproc164407_2053096_666689 ()}";
OdbcDataAdapter odbcAdapter = new OdbcDataAdapter();
OdbcCommand command = new OdbcCommand(queryString, odbcConnection);
try
{
odbcAdapter.SelectCommand = command;
odbcConnection.Open();
odbcAdapter.Fill(priceTable);
Console.WriteLine("Adding to SQL Server");
//serverConnection.copyTableToServer("Supplier_Master_Price", priceTable);
foreach(DataRow row in priceTable.Rows)
{
foreach (object item in row.ItemArray)
{
Console.WriteLine(item);
}
}
//serverConnection.removeDuplicatesSupplerMasterPrice();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
odbcConnection.Close();
}
}