Reading Binary data with datareader

Topics: Data Access Application Block
Feb 23, 2007 at 3:33 PM
What is the way with Data Access Application Block to read binary data (BLOB / IMAGE). It seem i have to set the
CommandBehavior.SequentialAccess behavior for reading the data as explained in this page

Many thanks,

Feb 23, 2007 at 4:34 PM
I haven't tried it using a DataReader. I have tried it with ExecuteScalar as I talk about in this tutorial:

Saving and Retrieving Images From SQL Server Using DAAB

All normal ADO.NET settings will apply when using the DAAB, because it uses ADO.NET under the covers.

If you can't set a particular setting using the DAAB, I recommend requesting for a solution via the IssueTracker.




David Hayden
Microsoft MVP C#
Jul 27, 2009 at 6:54 PM
Edited Jul 27, 2009 at 6:55 PM

I just want to share on how I was able to do it on my end:

byte[] byteArray = null;
DbCommand cmdGetData = Adapter.GetStoredProcCommand("uspSPNAME");
Adapter.AddInParameter(cmdGetData, "id", DbType.Int32, 1);
using (IDataReader data = Adapter.ExecuteReader(cmdGetData))

                while (data.Read())
                    byteArray = (byte[])data[0];