?
Solved

Read an Image field from database using stored procedure

Posted on 2006-05-30
8
Medium Priority
?
259 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:adktd
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16789559
1) .NET version?

2) Database type?

Bob
0
 
LVL 1

Author Comment

by:adktd
ID: 16789578
VS.NET version 2003

Database Sql Server 2000(Unfortunatelly i preffer 2005 better)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16789615
What do you mean by "all values in the rows that are returned by the stored procedure are objects"?

Bob
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:adktd
ID: 16789661
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 ?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16789698
dr["Photo"] should be a byte array.

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

Bob
0
 
LVL 1

Author Comment

by:adktd
ID: 16789799
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"];

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 16789820
Yeah, you're right on that on ;)

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

Bob
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question