| Devart.Data.SQLite Namespace : SQLiteDataReader Class |
Reads a forward-only stream of rows from a SQLite database.
For a list of all members of this type, see SQLiteDataReader members.
Devart.Common.DbDataReaderBase
Devart.Data.SQLite.SQLiteDataReader
[Visual Basic]
Public Class SQLiteDataReader
Inherits DbDataReaderBase[C#]
public class SQLiteDataReader : DbDataReaderBaseTo 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.
[C#]
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT DeptNo, DName FROM Dept";
SQLiteConnection sqConnection = new SQLiteConnection(myConnString);
SQLiteCommand sqCommand = new SQLiteCommand(mySelectQuery,sqConnection);
sqConnection.Open();
try
{
SQLiteDataReader sqReader = sqCommand.ExecuteReader();
// Always call Read before accessing data.
while (sqReader.Read())
{
Console.WriteLine(sqReader.GetInt32(0) + ", " + sqReader.GetString(sqReader.GetOrdinal("DName")));
}
// always call Close when done reading.
sqReader.Close();
// Close the connection when done with it.
}
finally
{
sqConnection.Close();
}
} [Visual Basic]
Public Sub ReadMyData(ByVal myConnString As String)
Dim mySelectQuery As String = "SELECT DeptNo, DName FROM Dept"
Dim sqConnection As New SQLiteConnection(myConnString)
Dim sqCommand As New SQLiteCommand(mySelectQuery, sqConnection)
sqConnection.Open()
Try
Dim sqReader As SQLiteDataReader = sqCommand.ExecuteReader()
' Always call Read before accessing data.
While sqReader.Read()
Console.WriteLine(sqReader.GetInt32(0).ToString() + ", " _
+ sqReader.GetString(sqReader.GetOrdinal("DName")))
End While
' always call Close when done reading.
sqReader.Close()
' Close the connection when done with it.
Finally
sqConnection.Close()
End Try
End SubSQLiteDataReader Members | Devart.Data.SQLite Namespace | SQLiteConnection Class | SQLiteCommand Class
© 2002 - 2013 Devart. All Rights Reserved.