Solved

image field in sql database convert to actual files

Posted on 2011-03-22
5
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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