0

在我看来,OleDbDataAdapter 在尝试为十进制 (28,3) 类型的 db 表列填充 DataSet 时不应该抛出异常。消息是“数值太大,无法放入 96 位小数”。你能检查一下吗,我对 ADO.NET 和 OLE DB 组件没有丰富的经验?

我们在应用程序中的 VB.NET 代码是这样的:

Dim dbDataSet As New DataSet
Dim dbDataAdapter As OleDbDataAdapter
Dim dbCommand As OleDbCommand
Dim conn As OleDbConnection
Dim connectionString As String

'parts where connectionString is set 

conn = New OleDbConnection(connectionString)

'part where sqlQuery is set but it ends up being "SELECT Price As 'Price' From PricebookView" - Price is of type decimal(28,3)

dbCommand = New OleDbCommand(sqlQuery, conn)
dbCommand.CommandTimeout = cmdTimeout
dbDataAdapter = New OleDbDataAdapter(dbCommand)
dbDataAdapter.Fill(dbDataSet)

最后一行是抛出异常的地方,堆栈跟踪的顶部是:

at System.Data.ProviderBase.DbBuffer.ReadNumeric(Int32 offset)     
at System.Data.OleDb.ColumnBinding.Value_NUMERIC()     
at System.Data.OleDb.ColumnBinding.Value()     
at System.Data.OleDb.OleDbDataReader.GetValues(Object[] values)     
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)     
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()     
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)     
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)     
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)     
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)     
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)     
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)     
...

我不确定它为什么尝试将值设置为 Int32。

谢谢你的时间!

4

0 回答 0