See Also

SQLiteDataReader Members  | Devart.Data.SQLite Namespace  | SQLiteConnection Class  | SQLiteCommand Class


Visual Basic


Show All

See AlsoLanguagesDevart.Data.SQLiteSend comments on this topic.

SQLiteDataReader Class

Devart.Data.SQLite Namespace : SQLiteDataReader Class

Reads a forward-only stream of rows from SQLite.

For a list of all members of this type, see SQLiteDataReader members.

Inheritance Hierarchy



[Visual Basic]
Public Class SQLiteDataReader    Inherits DbDataReaderBase
public class SQLiteDataReader : DbDataReaderBase


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

Devart.Common.DbDataReaderBase.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.


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.


public void ReadMyData(string myConnString)  { 
    SQLiteConnection sqConnection = new SQLiteConnection(myConnString); 
    SQLiteCommand sqCommand = (SQLiteCommand)sqConnection.CreateCommand(); 
    sqCommand.CommandText = "SELECT DeptNo, DName, Loc FROM Dept"; 
    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. 
        // Close the connection when done with it. 

[Visual Basic] 

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"
    Dim sqReader As SQLiteDataReader = sqCommand.ExecuteReader()
        ' 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
        ' always call Close when done reading.

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

See Also

SQLiteDataReader Members  | Devart.Data.SQLite Namespace  | SQLiteConnection Class  | SQLiteCommand Class



© 2008 - 2016 Devart. All Rights Reserved.