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

retrive image from ms access database

P: 3
Hi,

I am trying to extract image from database into picture box my code is

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3.         cnn = New OleDbConnection(strCn)
  4.  
  5.         Dim stream As New MemoryStream()
  6.         cnn.Open()
  7.         Dim command As New OleDbCommand("select img from llr where llrno = '" & TextBox1.Text & "'", cnn)
  8.         Dim image As Byte() = DirectCast(command.ExecuteScalar(), Byte())
  9.         stream.Write(image, 0, image.Length)
  10.  
  11.         Dim bitmap As New Bitmap(stream)
  12.         picBlob.Image = bitmap
  13.         cnn.Close()
  14.     End Sub
  15.  

but i am getting error "Parameter is not valid" the line "Dim bitmap As New Bitmap(stream)"

Plz help
Dec 14 '14 #1
Share this Question
Share on Google+
1 Reply


P: 1
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub btnGetPix_Click(sender As System.Object, e As System.EventArgs) Handles btnGetPix.Click
  4.         picPhoto.ImageLocation = txtUrlPictures.Text
  5.     End Sub
  6.  
  7.  
  8.     Private Sub rdoNormal_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rdoNormal.CheckedChanged
  9.         picPhoto.SizeMode = PictureBoxSizeMode.Normal
  10.     End Sub
  11.  
  12.     Private Sub rdoStretchImage_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rdoStretchImage.CheckedChanged
  13.         picPhoto.SizeMode = PictureBoxSizeMode.StretchImage
  14.     End Sub
  15.  
  16.     Private Sub rdoAutoSize_CheckedChanged(sender As System.Object, e As System.EventArgs)
  17.         picPhoto.SizeMode = PictureBoxSizeMode.AutoSize
  18.     End Sub
  19.  
  20.     Private Sub rdoCenterImage_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rdoCenterImage.CheckedChanged
  21.         picPhoto.SizeMode = PictureBoxSizeMode.CenterImage
  22.     End Sub
  23.  
  24.     Private Sub rdoZoom_CheckedChanged(sender As System.Object, e As System.EventArgs)
  25.         picPhoto.SizeMode = PictureBoxSizeMode.Zoom
  26.     End Sub
  27.  
  28. End Class

I would post the program on here but they did not have any attachment on here sorry about that.
Dec 15 '14 #2

Post your reply

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