By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,776 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,776 IT Pros & Developers. It's quick & easy.

Exporting binary images to jpg file

P: 77
Hi all,
I have table in sql which contains image as a binary code. I need to export all this images to jpg file. How should I do that?
I am using Vb.net.


Thanks,
Jul 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: 77
I found a way to do that :

sql = "Select Id ,value from tabl1"

con.Open()

MyCommand = New SqlCommand(sql, con)

rdr = MyCommand.ExecuteReader

While rdr.Read()

MyByte = rdr.Item("Value")

fs = New MemoryStream

fs.Write(MyByte, 0, MyByte.Length)

fs.Flush()

MyImg = Image.FromStream(fs, True)

MyImg.Save(rdr.Item("ID").ToString & ".JPG", System.Drawing.Imaging.ImageFormat.Jpeg)

fs.Close()

fs = Nothing

End While
Jul 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.