cancel
Showing results for 
Search instead for 
Did you mean: 

C# numeric precision

0 Kudos
2,063

I have a column in the Database with the following precision: Numeric (40,20) but When I try to read it it's raising me:

iAnywhere.Data.SQLAnywhere.SAException: 'Invalid data conversion' Probably it happens due to in the DataColumn the column precision is not so big. When I loading the data into my object, I declared this property as decimal, like the following:

public decimal? BigNumericColumn{ get; set; } In the loading data processing I'm doing the following.

DataTable schemaTable = dataReader.GetSchemaTable(); DataTable resultTable = new DataTable(typeof(T).Name);

foreach (DataRow dataRow in schemaTable.Rows) { DataColumn dataColumn = new DataColumn(); dataColumn.ColumnName = dataRow["ColumnName"].ToString();

if (lstColumnsToFilter.Contains(dataColumn.ColumnName) && filterEnabled) { lstIndexColumnToFilter.Add(countColumns); }

dataColumn.DataType = Type.GetType(dataRow["DataType"].ToString());
dataColumn.ReadOnly = (bool)dataRow["IsReadOnly"];
dataColumn.AutoIncrement = (bool)dataRow["IsAutoIncrement"];
dataColumn.AllowDBNull = true;

resultTable.Columns.Add(dataColumn);

} Do you know how could I fix it?

This is the complete error message:

at iAnywhere.Data.SQLAnywhere.SAException.CheckException(Int32 idEx) at iAnywhere.Data.SQLAnywhere.SADataReader.Read() at RiskAlm_DataExtraction.DataModels.IQ_Queries.GetDataTableFromDR[T](IDataReader dataReader, String path, List1 lstColumnsToFilter, String _sourceConnString) in D:\\C#_RiskAlm_Prototypes\\cabralf\\RiskAlm_DataExtraction\\RiskAlm_DataExtraction\\DataModels\\IQ_Queries.cs:line 277 at RiskAlm_DataExtraction.DataModels.IQ_Queries.<>c__DisplayClass5_01.b__0(ListFilter filterValue) in D:\\C#_RiskAlm_Prototypes\\cabralf\\RiskAlm_DataExtraction\\RiskAlm_DataExtraction\\DataModels\\IQ_Queries.cs:line 215 at System.Linq.Parallel.ForAllOperator1.ForAllEnumerator1.MoveNext(TInput& currentElement, Int32& currentKey) at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork() at System.Linq.Parallel.SpoolingTaskBase.Work()

Error 103 Message "Invalid data conversion" string

Accepted Solutions (0)

Answers (0)