'Getting an image from an Access database to display on VB.NET Windows Forms PictureBox
I'm trying to get an image stored in my Access database (via an SQL statement) to display in a picture box on a windows form application.
The code:
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\finla\Documents\userDB.accdb")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Users WHERE ID =" & LoginSystem.currentUSERID, con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
sdr.Read()
nicknameBox.Text = sdr.Item("Nickname")
imageBox.Image = sdr.Item("ProfileImage")
con.Close()
However, when using this code, I get an error saying: System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'System.Drawing.Image'.' - Anyone able to help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
