Solved

image field in sql database convert to actual files

Posted on 2011-03-22
5
243 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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