Dotnet-Project Framework documentation.

GenericDataHelper.ExecuteReader Method (IDbConnection, CommandType, String, IDataParameter[])

Execute a Command (that returns a resultset) against the database using the provided parameters.

public static IDataReader ExecuteReader(
   out IDbConnection aConnection,
   CommandType commandType,
   string commandText,
   params IDataParameter[] commandParameters
);

Parameters

aConnection
The connection used and that you must close.
commandType
The CommandType (stored procedure, text, etc.)
commandText
The stored procedure name or T-SQL command
commandParameters
An array of Parameters used to execute the command

Return Value

A DataReader containing the resultset generated by the command

Remarks

This method does not close the connection created. You must close the connection when you have finished to work with the reader.

Example

IDbConnection connection = null;
SqlDataReader dr = (SqlDataReader)ExecuteReader(out connection, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
/* Do work */
dr.Close();
dr.Dispose();
connection.Close();

See Also

GenericDataHelper Class | DotnetProject.Data Namespace | GenericDataHelper.ExecuteReader Overload List