Solved

VB.net Save image from memory stream

Posted on 2014-07-27
3
813 Views
Last Modified: 2014-07-30
How do I modify the following code to rather save the image as an image file on my hard drive

             Dim oID As String = D.Rows(r).Cells(1).Value
                                Dim sSQL As String = "Select Photo from Photos where ID = " & oID & ""
                                Dim cmd2 As New SqlCommand(sSQL, con)
                                Dim ImgStream As New IO.MemoryStream(CType(cmd2.ExecuteScalar, Byte()))
                                PictureBox1.Image = System.Drawing.Image.FromStream(ImgStream)
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40222901
Hi murbro;

This should work for you.

'' Where locationToSaveTo is a string with the path and filename on the disk.
System.IO.File.WriteAllBytes(locationToSaveTo, CType(cmd2.ExecuteScalar, Byte()));
0
 

Author Closing Comment

by:murbro
ID: 40229541
Thanks very much
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40229671
Not a problem, glad I was Ble to help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now