Hi all
I'm having some trouble trying to read an image from an Access Database.
The image is stored as an OLE Object.
This works fine:
txtItemName.Text = itemsReader("Name").ToString
But I get the error "Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image'." with this line:
pbItemImage.Image = itemsReader("Image")
I've searched google and this forum for a little under an hour and can't find anything that works..Code:Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Application.StartupPath & "\t4c.mdb") Dim query As String query = "SELECT Name, Enc, Req_Str, Req_End, Req_Agi, Req_Int, Req_Wis, Req_Att, Bonus_AC, Bonus_Dodge_Fix, Bonus_Str, Bonus_End, Bonus_Agi, Bonus_Wis, Bonus_Int, Bonus_Air_Power, Bonus_Dark_Power, Bonus_Earth_Power, Bonus_Fire_Power, Bonus_Light_Power, Bonus_Water_Power, Bonus_Air_Resist, Bonus_Dark_Resist, Bonus_Earth_Resist, Bonus_Fire_Resist, Bonus_Water_Resist, Bonus_AP, Bonus_Arc, Bonus_Att, Bonus_Hide, Bonus_Parry, Bonus_PB, Bonus_RH, Bonus_SB, Bonus_Meditate, Bonus_Dmg FROM Gloves WHERE Name= '" & lstGloves.SelectedValue & "'" Dim command As New OleDbCommand(query, conn) conn.Open() Dim itemsReader As OleDbDataReader = command.ExecuteReader itemsReader.Read() txtItemName.Text = itemsReader("Name").ToString pbItemImage.Image = itemsReader("Image") conn.Close()
Any help?




Reply With Quote