I know this has been frequently asked by many here, but I wouldn't have asked if I haven't tried most of the solutions given on this website.
I'm having trouble reading images of receipts from ms-access to a picturebox in vb.net.
Here's the code I currently have.
Dim i = DataGridView1.CurrentRow.Index
Dim Dir As String = Path.GetDirectoryName(Application.ExecutablePath) & "\"
Dim Connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Dir & "DB1.accdb")
Dim SQL As String = "SELECT Receipt FROM [Inventory] WHERE ID=@DID"
Dim command As New OleDbCommand(SQL, Connection)
command.Parameters.AddWithValue("@DID", DataGridView1.Item(0, i).Value)
Connection.Open()
Using oleDBCmd As OleDb.OleDbCommand = Connection.CreateCommand()
oleDBCmd.CommandType = CommandType.Text
oleDBCmd.CommandText = SQL
Using oleDbReader As OleDb.OleDbDataReader = oleDBCmd.ExecuteReader()
oleDbReader.Read()
Dim ImageBytes As Byte() = CType(oleDbReader(0), Byte())
Dim ms As New MemoryStream(ImageBytes)
FormReciept.Show()
FormReceipt.PictureBox1.Image = Image.FromStream(ms)
End Using
End Using
Connection.Close()
Based on the selected field of a specific item, it will retrieve its receipt based on the ID number, and preview it in another form where the picture box is.
Here's the error I'm getting.
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred
in System.Data.dll
Additional information: No value given for one or more required parameters.
Any help would be appreciated. Thank you.