Data Reader

There are different kinds of data readers. What is important to note is that, as the name suggests, a data reader reads data. It is a broad category of objects used to sequentially read data from a data source.

There are data readers that are designed as general-purpose MAX/MSP tools for the production of data sonifications and other applications in which reading multi-column spreadsheet data is necessary. In this case, the datareader object allows users to read and output each column of a multi-column asci file (up to 64 columns) through a separate outlet. Each line can be output sequentially, forward or backward, or by indicating a specific line number. The object also includes simple interpolation and smoothing between lines.

Data readers provide a very efficient way to access data, and can be thought of as a Firehose cursor from ASP Classic, except that no server-side cursor is used. A data reader analyzes a Tabular Data Stream from Microsoft SQL Server, and other methods of retrieving data from other sources.

Usually, a data reader is associated with a “command” object that contains the query, optionally any parameters, and the connection object to run the query on.

There are some IT personnel that substitute data reader for a data table, however many programmers have experienced connection bloat when doing this method. A data reader can only be used against an (already) open database connection; that connection isn't closed until the data reader's “dispose” method is called. If a debarment is thrown while the data is being processed, the “dispose” method will never be called if the programmer writes code explicitly declaring and disposing the data reader.