Link to home
Start Free TrialLog in
Avatar of adktd
adktdFlag for United States of America

asked on

Read an Image field from database using stored procedure

Hi you experts.

Is there a way to read an image field from an sql database using a stored procedure?
My problem is that all values in the rows tha are returned by the stored procedure are objects and can only be converted to string.I want to be able to take the Photo field that is being return by the stored procedure and asign it to a byte variable.

Any help will be very appreciated.

Thank you all in advance.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

1) .NET version?

2) Database type?

Bob
Avatar of adktd

ASKER

VS.NET version 2003

Database Sql Server 2000(Unfortunatelly i preffer 2005 better)
What do you mean by "all values in the rows that are returned by the stored procedure are objects"?

Bob
Avatar of adktd

ASKER

For example : If an sp returns a dataset that has one table with a column named photo and a column named EmployeeName

string empName;
Byte empPhoto;

foreach(DataRow dr in myDataSet.Table[0].rows)
{
   empname = dr["EmployeeName"].ToStirng();
   
   dr["Photo"] -------------> is object
}

How can i assign dr["Photo"] to empPhoto ?
dr["Photo"] should be a byte array.

byte[] data = dr["Photo"];

Bob
Avatar of adktd

ASKER

When i try to complile i get the same error as i did before "Cannot implicitly convert type 'object' to 'byte[]'
byte[] data = dr["Photo"];

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial