Image from MS Access in WPF

55 views Asked by At

I'm currently working with MS Access and WPF with an OleDb. I then read the data using WPF using C#. Now I have entered images in Access as a field (attachment) and would like to display them in WPF. Work with an OleDbReader. Is there something like reader.GetImage(0)? Thanks in advance

SQL Syntax and maybe C# Code

1

There are 1 answers

2
Andreas On

The easiest way would be, to get the image data as byte[] and bind it to an Image.Source in WPF. [email protected]

in WPF/XAML

<Image Source="{Binding Path=ImageData, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
var length = (int) reader.GetBytes(columnIndexWhereTheImageDataIsStored,0,null,int.MaxValue);
var buffer = new byte[length];
reader.GetBytes(columnIndexWhereTheImageDataIsStored,0,buffer,0,buffer.Length);