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

Retrive an Image from database

P: n/a
Hi EveryBody:

I have the following code that I used in my application to retive image from
database:

Dim cnn As New SqlConnection("Data Source=localhost;Initial
Catalog=Husam;Integrated Security=True")
Dim cmd As SqlCommand
Dim sql As String
cnn.Open()
Sql = "SELECT Name,Picture FROM Pic"
cmd = New SqlCommand(sql, cnn)
Dim myReader As SqlDataReader = cmd.ExecuteReader()
While (myReader.Read())
byt = myReader.GetValue(1)
ms = New MemoryStream(byt)
End While
PictureBox1.Image = Image.FromStream(ms)
PictureBox1.ImageLocation = PictureBoxSizeMode.CenterImage
cnn.Close()

When I debug this project I got an error message that said:

Parameter is not valid and yellow line in
Pictuerbox1.image=image.fromstream(ms)

any help in this issue or any direction about how to retrive image from
database and disply it will be appreciated

regard's

Husam
Nov 5 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Husam,

This is a tip how to handle this.

It is using a reader from disk. There are a lot of samples using other
methods on our side. However this one is in my idea the best showing the
fundementals.

http://www.vb-tips.com/Image2ByteArray.aspx

Cor
Nov 5 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.