Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -120,10 +120,19 @@
private void CheckClosed()
{
if (_command == null)
throw new InvalidOperationException("DataReader has been closed");
}
+
+ ///
+ /// Throw an error if a row is not loaded
+ ///
+ private void CheckValidRow()
+ {
+ if (_readingState != 0)
+ throw new InvalidOperationException("No current row");
+ }
///
/// Enumerator support
///
/// Returns a DbEnumerator object.
@@ -169,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)
{
+ CheckValidRow();
SQLiteType t = GetSQLiteType(i);
if (t.Type == typ) return;
// Coercable type, usually a literal of some kind
@@ -596,11 +606,10 @@
///
/// 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();
int nMax = _fieldCount;
if (values.Length < nMax) nMax = values.Length;
for (int n = 0; n < nMax; n++)
{