dotConnect for SQLite Documentation
SQLiteDataReader Class
Members  Example  See Also  Send comments on this topic.
Devart.Data.SQLite Namespace : SQLiteDataReader Class

Reads a forward-only stream of rows from SQLite.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbDataReader
         Devart.Common.DbDataReaderBase
            Devart.Data.SQLite.SQLiteDataReader

Syntax

Visual Basic (Declaration) 
Public Class SQLiteDataReader 
   Inherits Devart.Common.DbDataReaderBase
   Implements IEnumerableIDataReaderIDataRecordIDisposable 
C# 
public class SQLiteDataReader : Devart.Common.DbDataReaderBase, IEnumerableIDataReaderIDataRecordIDisposable  

Remarks

To create a SQLiteDataReader, you must call the ExecuteReader method of the SQLiteCommand object, rather than directly using a constructor.

System.Data.Common.DbDataReader.IsClosed and RecordsAffected are the only properties that you can call after the SQLiteDataReader is closed. In some cases, you must call Close before you can call RecordsAffected.

Example

The following example creates a SQLiteConnection, a SQLiteCommand, and a SQLiteDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the SQLiteDataReader, then the SQLiteConnection.
C#csharpCopy Code
public void ReadMyData(string myConnString)  {
        SQLiteConnection sqConnection = new SQLiteConnection(myConnString);
        SQLiteCommand sqCommand = (SQLiteCommand)sqConnection.CreateCommand();
        sqCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Dept";
        sqConnection.Open();
        SQLiteDataReader sqReader = sqCommand.ExecuteReader();
        try {
                // Always call Read before accessing data.
                while (sqReader.Read()) {
                Console.WriteLine(sqReader.GetInt32(0).ToString() + " " + 
                sqReader.GetString(1) + " " + sqReader.GetString(2));
        }
        }
        finally {
                // always call Close when done reading.
                sqReader.Close();

                // Close the connection when done with it.
                sqConnection.Close();
        }
}
C#Visual BasicCopy Code
Public Sub ReadMyData(ByVal myConnString As String)
        Dim sqConnection As New SQLiteConnection(myConnString)
        Dim sqCommand As SQLiteCommand = sqConnection.CreateCommand()
                sqCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Dept"
        sqConnection.Open()
        Dim sqReader As SQLiteDataReader = sqCommand.ExecuteReader()
        Try
                ' Always call Read before accessing data.
                While sqReader.Read()
                        Console.WriteLine(String.Concat(sqReader.GetInt32(0).ToString(), " ", _
                        sqReader.GetString(1), " ", sqReader.GetString(2)))
                End While
        Finally
                ' always call Close when done reading.
                sqReader.Close()

                        ' Close the connection when done with it.
                        sqConnection.Close()
        End Try
End Sub

Requirements

Namespace: Devart.Data.SQLite

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also