Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -178,10 +178,11 @@
///
/// The index of the column to type-check
/// The type we want to get out of the column
private void VerifyType(int i, DbType typ)
{
+ CheckClosed();
CheckValidRow();
SQLiteType t = GetSQLiteType(i);
if (t.Type == typ) return;
@@ -338,10 +339,11 @@
///
/// The index of the column to retrieve
/// Type
public override Type GetFieldType(int i)
{
+ CheckClosed();
return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i));
}
///
/// Returns a column as a float value
@@ -638,10 +640,12 @@
///
/// The index of the column to retrieve
/// object
public override object GetValue(int i)
{
+ CheckClosed();
+
SQLiteType typ = GetSQLiteType(i);
return _activeStatement._sql.GetValue(_activeStatement, i, ref typ);
}
@@ -650,16 +654,21 @@
///
/// The array to fill with values from the columns in the current resultset
/// The number of columns retrieved
public override int GetValues(object[] values)
{
+ CheckClosed();
+
+ SQLiteType typ;
int nMax = _fieldCount;
if (values.Length < nMax) nMax = values.Length;
+
for (int n = 0; n < nMax; n++)
{
- values.SetValue(GetValue(n), n);
+ typ = GetSQLiteType(n);
+ values[n] = _activeStatement._sql.GetValue(_activeStatement, n, ref typ);
}
return nMax;
}
@@ -783,11 +792,10 @@
///
/// The index of the column to retrieve
/// A SQLiteType structure
private SQLiteType GetSQLiteType(int i)
{
- CheckClosed();
if (_fieldTypeArray == null) _fieldTypeArray = new SQLiteType[_fieldCount];
if (_fieldTypeArray[i].Affinity == TypeAffinity.Uninitialized || _fieldTypeArray[i].Affinity == TypeAffinity.Null)
_fieldTypeArray[i].Type = SQLiteConvert.TypeNameToDbType(_activeStatement._sql.ColumnType(_activeStatement, i, out _fieldTypeArray[i].Affinity));
return _fieldTypeArray[i];