Solved

image field in sql database convert to actual files

Posted on 2011-03-22
5
241 Views
Last Modified: 2012-05-11
I have a bunch of binary data in my database in a image fields... I want to convert the binary files to
ACTUAL FILES  that i can save in a folder... can somebody tell me how to do this?

I will do this where datareader is the image field

 Do while
    dr("imagefield") 'DO SOMETHING
loop



0
Comment
Question by:vbnetcoder
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35192567
Unless I'm way off, the data should be coming back as a byte array [ Byte() ]. You could load that into a Stream for writing (this is an overview; you'll need to tweak it):
Do While
    Using ms As New System.IO.MemoryStream(DirectCast(dr("imagefield"), Byte()))
        Using img As Image = Image.FromStream(ms)
            img.Save("someFilename.someExt")
        End Using
    End Using
Loop

Open in new window

0
 

Author Comment

by:vbnetcoder
ID: 35192833
That worked, Thank you!  Can you tell how I can tell for sure that there is a image?  Some fields may return as null.

Thank you
0
 

Author Comment

by:vbnetcoder
ID: 35192895
Never mind i got it
0
 

Author Closing Comment

by:vbnetcoder
ID: 35192901
ty
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35193084
NP. Glad to help  = )
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net winforms sizing/resolution? 4 42
Very Large data in MYSQL 7 73
VB.Net. Reading xml value 6 30
C# MVC Insert Multiple Row into DB 2 31
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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