Midatareader – Pitney Bowes MapXtreme User Manual

Page 185

Advertising
background image

Chapter 8: Working with Data

MapInfo ADO.NET Data Provider

MapXtreme v7.1

192

Developer Guide

MIDataReader

The MIDataReader provides forward-only, read-only access to the data returned from executing a
SQL Select statement. To create a MIDataReader, you must call the ExecuteReader method of the
MICommand object, rather than directly using a constructor.

The MapInfo Data Provider allows multiple MIDataReader instances to be in use on the same
connection. However, if the Table being accessed resides on a Microsoft SQL Server database, only
one MIDataReader may be open at a time.

IsClosed and RecordsAffected are the only properties that you can call after the MIDataReader is
closed.Although the RecordsAffected property may be accessed while the MIDataReader exists,
always call Close before returning the value of RecordsAffected to ensure an accurate return value.

You must explicitly call the Close method when you are through using the MIDataReader.

When accessing the DataReader through the IEnumerator or IFeatureEnumerator interface, Close()
is automatically called when MoveNext() returns false. Only one enumerator can be used on a
DataReader.

L

For optimal performance, MIDataReader tries to avoid creating unnecessary objects or
making unnecessary copies of data. As a result, multiple calls to methods such as GetValue
may return a reference to the same object. Use caution if you are modifying the underlying
value of the objects returned by methods such as GetValue.

The MIDataReader provides a means of reading a forward-only stream of rows from the MapInfo
data provider. This cursor type is the best performing for accessing a selection of rows since there is
little setup or overhead.

Scrollable Data Readers

MIScrollableReader derives from MIDataReader and offers forward and reverse reading. Some of
the options available with MIScrollableReader include:

ReadPrevious

Rewind

Unwind

ReadTop

ReadBottom

AtTop / AtBottom

L

An MIScrollableReader is more expensive to create than MIDataReader. This is the most
expensive cursor since there is setup and extra resources necessary to keep track of record
order to allow scrolling. Use this cursor only if you need to scroll through the record set.

Advertising