Hi,
I have a table which contains a BLOB field for image. I would like
to copy a picture from
database directly to a picture box control and I have tried the
following:
Dim c as Integer
c = sDataSet.Tables(0).Rows.Count
Dim bytBLOBData() As Byte =
sDataSet.Tables(0).Rows(c-1)("Image")
Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData)
I get the error "Invalid Parameter user" after the following line:
Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter
user" error.
Dim bytBLOBData() As Byte =
CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte())
Can anyone give me an idea please, thanks in advance.
Regards. 10 2336
wandii,
try reading the data from your blob into a SqlBinary, and using this to
contruct your memory stream using the SqlBinarys Value property
hth
"wandii" wrote: Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following:
Dim c as Integer c = sDataSet.Tables(0).Rows.Count
Dim bytBLOBData() As Byte = sDataSet.Tables(0).Rows(c-1)("Image") Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData)
I get the error "Invalid Parameter user" after the following line: Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter user" error. Dim bytBLOBData() As Byte = CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte())
Can anyone give me an idea please, thanks in advance.
Regards.
Hi guy,
Thanks for the reply. I am not familiar with the SqlBinary could
you please give
me a small example on this. Thanks in advance.
guy wrote: wandii, try reading the data from your blob into a SqlBinary, and using this to contruct your memory stream using the SqlBinarys Value property
hth
Hi guy,
Thanks for the reply. I am not familiar with the SqlBinary could
you please give
me a small example on this. Thanks in advance.
guy wrote: wandii, try reading the data from your blob into a SqlBinary, and using this to contruct your memory stream using the SqlBinarys Value property
hth
Hi guy,
Thanks for the reply. I am not familiar with the SqlBinary could
you please give
me a small example on this. Thanks in advance.
guy wrote: wandii, try reading the data from your blob into a SqlBinary, and using this to contruct your memory stream using the SqlBinarys Value property
hth
On 28 Jun 2006 08:32:58 -0700, "wandii" <wa****@yahoo.com> wrote: Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following:
Dim c as Integer c = sDataSet.Tables(0).Rows.Count
Dim bytBLOBData() As Byte = sDataSet.Tables(0).Rows(c-1)("Image") Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData)
I get the error "Invalid Parameter user" after the following line: Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter user" error. Dim bytBLOBData() As Byte = CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte())
Can anyone give me an idea please, thanks in advance.
Regards.
This example reads a Blob in an Access database from the field named
"ImgData" and displays the result in PictureBox1.
Dim mStream As New System.IO.MemoryStream
Dim pData() As Byte = _
DirectCast(tblSat.Rows(idxRow).Item("ImgData"), Byte())
mStream.Write(pData, 0, Convert.ToInt32(pData.Length))
Dim bm As Bitmap = New Bitmap(mStream, False)
PictureBox1.Image = bm
mStream.Dispose()
Gene
Hello gene,
If the image is stored as an OLE image you will need to start reading at
byte 78 instead of byte 0.
-Boo On 28 Jun 2006 08:32:58 -0700, "wandii" <wa****@yahoo.com> wrote:
Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following: Dim c as Integer c = sDataSet.Tables(0).Rows.Count Dim bytBLOBData() As Byte = sDataSet.Tables(0).Rows(c-1)("Image") Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData) I get the error "Invalid Parameter user" after the following line: Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter user" error. Dim bytBLOBData() As Byte = CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte()) Can anyone give me an idea please, thanks in advance.
Regards. This example reads a Blob in an Access database from the field named "ImgData" and displays the result in PictureBox1.
Dim mStream As New System.IO.MemoryStream Dim pData() As Byte = _ DirectCast(tblSat.Rows(idxRow).Item("ImgData"), Byte()) mStream.Write(pData, 0, Convert.ToInt32(pData.Length)) Dim bm As Bitmap = New Bitmap(mStream, False) PictureBox1.Image = bm mStream.Dispose() Gene
On Wed, 28 Jun 2006 22:19:43 +0000 (UTC), GhostInAK
<gh*******@gmail.com> wrote: Hello gene,
If the image is stored as an OLE image you will need to start reading at byte 78 instead of byte 0.
-Boo
Yes. Somehow I always equate "BLOB" with "0" and Image/Picture with
"78".
Gene On 28 Jun 2006 08:32:58 -0700, "wandii" <wa****@yahoo.com> wrote:
Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following: Dim c as Integer c = sDataSet.Tables(0).Rows.Count Dim bytBLOBData() As Byte = sDataSet.Tables(0).Rows(c-1)("Image") Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData) I get the error "Invalid Parameter user" after the following line: Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter user" error. Dim bytBLOBData() As Byte = CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte()) Can anyone give me an idea please, thanks in advance.
Regards. This example reads a Blob in an Access database from the field named "ImgData" and displays the result in PictureBox1.
Dim mStream As New System.IO.MemoryStream Dim pData() As Byte = _ DirectCast(tblSat.Rows(idxRow).Item("ImgData"), Byte()) mStream.Write(pData, 0, Convert.ToInt32(pData.Length)) Dim bm As Bitmap = New Bitmap(mStream, False) PictureBox1.Image = bm mStream.Dispose() Gene
Thanks for great example of reading Blob and/or OLE Image. Do you have an
example of how to write from a picture box image to the datatable? Thanks.
--
Dennis in Houston
"gene kelley" wrote: On Wed, 28 Jun 2006 22:19:43 +0000 (UTC), GhostInAK <gh*******@gmail.com> wrote:
Hello gene,
If the image is stored as an OLE image you will need to start reading at byte 78 instead of byte 0.
-Boo
Yes. Somehow I always equate "BLOB" with "0" and Image/Picture with "78".
Gene On 28 Jun 2006 08:32:58 -0700, "wandii" <wa****@yahoo.com> wrote:
Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following: Dim c as Integer c = sDataSet.Tables(0).Rows.Count Dim bytBLOBData() As Byte = sDataSet.Tables(0).Rows(c-1)("Image") Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData) I get the error "Invalid Parameter user" after the following line: Me.PictureBox2.Image = Image.FromStream(stmBLOBData)
I also tried changing the following line - still "Invalid Parameter user" error. Dim bytBLOBData() As Byte = CType(sDataSet.Tables(0).Rows(c-1)("Image"), Byte()) Can anyone give me an idea please, thanks in advance.
Regards.
This example reads a Blob in an Access database from the field named "ImgData" and displays the result in PictureBox1.
Dim mStream As New System.IO.MemoryStream Dim pData() As Byte = _ DirectCast(tblSat.Rows(idxRow).Item("ImgData"), Byte()) mStream.Write(pData, 0, Convert.ToInt32(pData.Length)) Dim bm As Bitmap = New Bitmap(mStream, False) PictureBox1.Image = bm mStream.Dispose() Gene
On Thu, 29 Jun 2006 17:18:02 -0700, Dennis
<De****@discussions.microsoft.com> wrote: Thanks for great example of reading Blob and/or OLE Image. Do you have an example of how to write from a picture box image to the datatable? Thanks.
Assume loading a PictureBox Image from a file (strFilename)
Dim myStream As IO.FileStream = New IO.FileStream(strFilename, _
IO.FileMode.Open, IO.FileAccess.Read)
With myStream
Dim myImageBuffer(CType(.Length, Integer)) As Byte
.Read(myImageBuffer, 0, Convert.ToInt32(.Length))
'Display the image
Dim PreviewlImage As Bitmap = New Bitmap(myStream)
me.PictureBox.Image = PreviewImage
'myImageBuffer is the BLOB
'Pass it to whatever Insert/Update method you are using
'Or you can store it in the Tag property for later use
Me.PictureBox.Tag = myImageBuffer
.Close()
End With
Tag usage:
Dim ImgData() As Byte = DirectCast(Me.PictureBox.Tag, Byte())
where ImgData() is what goes into the Blob field in the table.
Gene
Thanks for the technique.
--
Dennis in Houston
"gene kelley" wrote: On Thu, 29 Jun 2006 17:18:02 -0700, Dennis <De****@discussions.microsoft.com> wrote:
Thanks for great example of reading Blob and/or OLE Image. Do you have an example of how to write from a picture box image to the datatable? Thanks.
Assume loading a PictureBox Image from a file (strFilename)
Dim myStream As IO.FileStream = New IO.FileStream(strFilename, _ IO.FileMode.Open, IO.FileAccess.Read) With myStream Dim myImageBuffer(CType(.Length, Integer)) As Byte .Read(myImageBuffer, 0, Convert.ToInt32(.Length))
'Display the image Dim PreviewlImage As Bitmap = New Bitmap(myStream) me.PictureBox.Image = PreviewImage
'myImageBuffer is the BLOB 'Pass it to whatever Insert/Update method you are using 'Or you can store it in the Tag property for later use Me.PictureBox.Tag = myImageBuffer
.Close() End With
Tag usage: Dim ImgData() As Byte = DirectCast(Me.PictureBox.Tag, Byte())
where ImgData() is what goes into the Blob field in the table.
Gene This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stephen Williams |
last post by:
Does Microsoft have a comment the possible bug on the
PictureBox Class. Here is the exchange I had on the
Experts-Exchange regarding this issue:
From Z_Beeblebrox:
Hi,
I believe it is...
|
by: active |
last post by:
I have a picturebox usercontrol sitting on a usercontrol. I need a KeyPress
event in the PictureBox.
I suppose I could have a property in the pictureBox that is accessed by a
call in a...
|
by: Tom |
last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to
stretched. I then load an image into that form and display it. As the user
moves the mouse over the form, I want to get and...
|
by: Rich |
last post by:
Hello,
I want to simulate the dynamic thumbnail display of Windows Explorer (winxp)
on a form or pannel container. If I place a picture box on my container
form/pannel and dimension it to the...
|
by: TomA |
last post by:
Hi All,
I have a picturebox on a form containing the photo of a person. As you
advance through the records, the photo updates. Rather than storing the
images in an inefficient blob field in a...
|
by: dlamar |
last post by:
I'm using VB.NET with 2.0 - I have a number of PictureBoxes in my application - all of which use a context menu to change the associated Image to one of 5 options. I need to maintain the state of...
|
by: =?Utf-8?B?Sm9uIFBhcnJ5?= |
last post by:
Hi,
I've got a Picturebox, into which I am putting a frame bitmap from a video
camera. The camera bitmap is larger than the picturebox, which has SizeMode
set to "Zoom" which causes the bitmap...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Using VS2005 with .NET Framework 2.0
I'm using the the System.Windows.Forms.PictureBox to display a bitmap when
the PictureBox.SizeMode is PictureBoxSizeMode.StretchImage
The PictureBox can be...
|
by: AWW |
last post by:
XP VB 2005 running an example from help that creates a picturebox in
code - the picturebox is not created.
If I comment out the "Dim Box as New PictureBox" and create it in
Design mode - the...
|
by: leshka82 |
last post by:
I have recently designed a Winform Image drag & drop utility. The approach I took was to have a Panel control serve as a destination for multiple file drop. Once the user dragged & dropped the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |