VistaDB 5
Members  Example 






VistaDB.Provider Namespace : VistaDBDataReader Class
VistaDBDataReader Class
Provides a way of reading a forward-only stream of rows from a VistaDB database.
Syntax
'Declaration
 
<System.Reflection.DefaultMemberAttribute("Item")>
Public NotInheritable Class VistaDBDataReader 
   Inherits System.Data.Common.DbDataReader
'Usage
 
Dim instance As VistaDBDataReader
[System.Reflection.DefaultMember("Item")]
public sealed class VistaDBDataReader : System.Data.Common.DbDataReader 
public class VistaDBDataReader = class(System.Data.Common.DbDataReader)sealed; 
System.Reflection.DefaultMemberAttribute("Item")
public sealed class VistaDBDataReader extends System.Data.Common.DbDataReader
[System.Reflection.DefaultMember("Item")]
public __gc __sealed class VistaDBDataReader : public System.Data.Common.DbDataReader 
[System.Reflection.DefaultMember("Item")]
public ref class VistaDBDataReader sealed : public System.Data.Common.DbDataReader 
Example
public void Simple()
{
    using( VistaDBConnection conn = new VistaDBConnection(
        @"Open Mode=NonExclusiveReadWrite;Data Source=simple.vdb5") )
    {
        Assert.IsNotNull(conn);
        // Open the connection and verify the state is set correctly
        conn.Open();
        Assert.IsTrue(conn.State == ConnectionState.Open);
 
        // This should return one column AMOUNT = 20
        using( VistaDBCommand cmd = new VistaDBCommand("select sum(10+10) as amount", 
             conn) )
        {
            VistaDBDataReader reader = cmd.ExecuteReader();
            Assert.IsNotNull(reader);
            Assert.IsNotNull(reader[0]);
            Assert.IsTrue(reader.HasRows);
            
            // SELECT commands should generate a -1 for RecordsAffected
            Assert.AreEqual(reader.RecordsAffected, -1);
            Assert.IsTrue(reader["amount"].Equals("20"));
        }
    }
}
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbDataReader
         VistaDB.Provider.VistaDBDataReader

Requirements

This is considered an online operation, any rows or foreign keys locked as a result of this operation will be held until this reader is destroyed.

Each row of the result is only built up as it is needed and after each row is used and the current pointer is moved forward the previous row is released for garbage collection. This allows an extremely large collection of rows to be iterated and processed in a fixed, modest amount of memory as compared to using a DataSet.

See Also