Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
I have path and its image in a table like

C:\Users\Public\Pictures\Sample Pictures\Koala.jpg <binary data="">
C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg <binary data="">

I need to retrieve images from database and display in listview


Can any 1 help !!

Thanks in advance

I used the below code

VB
    qry = ""
    qry = "SELECT Image FROM  T_ImageStore"
    Dim adp As New OleDbDataAdapter
    adp.SelectCommand = New OleDbCommand(qry, conn)
    Dim ds As New DataSet()
    adp.Fill(ds, "BLOBTest")
    Dim c As Integer = ds.Tables("BLOBTest").Rows.Count
    Dim bytBLOBData() As Byte = _
           dt.Rows(c - 1)("Image")

    PictureBox1.Image = convertbyteArrayToImage(bytBLOBData)

Private Function convertbyteArrayToImage(ByVal byteArrayIn As Byte()) As Image
    Dim ms As MemoryStream = New MemoryStream(byteArrayIn)
    Dim returnImage As Image = Image.FromStream(ms)
    Return returnImage
End Function


i get error:

An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll

Additional information: Parameter is not valid
Posted
Updated 9-Oct-13 3:16am
v2
Comments
Kschuler 8-Oct-13 13:57pm    
Is the actual image in the database, in a blob field? Or is it just a string of the path it's located in? If the image is IN the database, you should research blobs (Binary Large Objects) If not, then just use System.IO classes to open and/or work with the image files.
Usha Muhunthan 9-Oct-13 1:17am    
I have saved image by converting to Binary data, There is no path saved in DB
Usha Muhunthan 9-Oct-13 1:48am    
I used the below code

qry = ""
qry = "SELECT Image FROM T_ImageStore"
Dim adp As New OleDbDataAdapter
adp.SelectCommand = New OleDbCommand(qry, conn)
Dim ds As New DataSet()
adp.Fill(ds, "BLOBTest")
Dim c As Integer = ds.Tables("BLOBTest").Rows.Count
Dim bytBLOBData() As Byte = _
dt.Rows(c - 1)("Image")

PictureBox1.Image = convertbyteArrayToImage(bytBLOBData)

Private Function convertbyteArrayToImage(ByVal byteArrayIn As Byte()) As Image
Dim ms As MemoryStream = New MemoryStream(byteArrayIn)
Dim returnImage As Image = Image.FromStream(ms)
Return returnImage
End Function

i get error:

An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll

Additional information: Parameter is not valid

Can u help in this
RedDk 9-Oct-13 11:23am    
Repost.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900