prabhuforum
New member
- Joined
- Mar 30, 2007
- Messages
- 1
- Programming Experience
- 1-3
Hi Guys,
I am in need of help from you people
I am facing problem in retrieving image from database.
Problem
I have sql database 2000
I have one table...
It has one column named IMAGE type image 16
Iam using VB.Net
IN my form, I have a picturebox.
I drag the image and placed the image and i saved the image in the database
It got save in binary.. ..byte Array i suppose.
This is code for Saving data
Then i execute the query..it got saved
The real problem is while retrieving..
I bound the entire dataset of my table to a datagrid...
In the datagrid..last column is IMAGE..showing ..byte Array[] ..ok
When i select a row in the datagrid..iam displaying all information in the screen below the datagrid.
My code for that..
Now with this iam displaying all the data from selected row..
My problem
While trying to display the image to the picture box...
It is giving error...
my code:
It is giving error in the line
pbEmp.Image = Image.FromStream(ms)
Invalid parameter is used..
Please let me know the solution for this problem i need immediate reply plssssssssss
I am in need of help from you people
I am facing problem in retrieving image from database.
Problem
I have sql database 2000
I have one table...
It has one column named IMAGE type image 16
Iam using VB.Net
IN my form, I have a picturebox.
I drag the image and placed the image and i saved the image in the database
It got save in binary.. ..byte Array i suppose.
This is code for Saving data
VB.NET:
ostrUpdate.Append("',IMAGE ='")
'ostrUpdate.Append(Me.pbEmp.Image)
Dim ms AsNew System.IO.MemoryStream
Dim im As Image
im = pbEmp.Image
im.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim b(ms.Length - 1) AsByte
ms.Position = 0
ms.Read(b, 0, ms.Length)
ostrUpdate.Append(b)
ostrUpdate.Append("'")
ostrUpdate.Append(" WHERE ")
ostrUpdate.Append(" EMP_NO ='")
ostrUpdate.Append(Me.txtEmpNo.Text.Trim)
ostrUpdate.Append("'")
Return ostrUpdate.ToString
The real problem is while retrieving..
I bound the entire dataset of my table to a datagrid...
In the datagrid..last column is IMAGE..showing ..byte Array[] ..ok
When i select a row in the datagrid..iam displaying all information in the screen below the datagrid.
My code for that..
VB.NET:
dsAssoc is a datarow...
drAssoc = dsAssociates.Tables(0).RowsdgAssociates.CurrentCell.RowNumber)
My problem
While trying to display the image to the picture box...
It is giving error...
my code:
VB.NET:
pbEmp is my picture box
IfNot IsDBNull(drAssoc("IMAGE")) Then
Dim b() As Byte
b = drAssoc("IMAGE")
Dim pic() As Byte = CType(drAssoc.Item("IMAGE"), Byte())
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(pic)
pbEmp.Image = Image.FromStream(ms)
End if
It is giving error in the line
pbEmp.Image = Image.FromStream(ms)
Invalid parameter is used..
Please let me know the solution for this problem i need immediate reply plssssssssss
Last edited by a moderator: