Solved

VB.net Save image from memory stream

Posted on 2014-07-27
3
921 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
[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
  • 2
3 Comments
 
LVL 63

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 63

Expert Comment

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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to open form using item in Listbox. 8 28
get combo value in class 5 23
VB.Net creating Contact in Outlook 1 48
Groupbox Control ? 2 27
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 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