Solved

VB.net Save image from memory stream

Posted on 2014-07-27
3
788 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
Comment Utility
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
Comment Utility
Thanks very much
0
 
LVL 62

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

10 Experts available now in Live!

Get 1:1 Help Now