Almost forgot. In my last tutorial, I-tell-you-to-save Image/photo into Oracle database. But, there are another problem, how do I read and view it from Oracle database? Don ' t worry, it's very easy-to-do. Just follow these steps and you'll able to the load Image from Oracle database. And one thing, I ' m using DataBinding technique in the This tutorial, so you had to learn abut it first. Unfortunately, I ' m too lazy to write about it. So, maybe next time I'll write about databinidng in WPF.
1. Create a new WPF application (don ' t tell me what you don't know how). Name it wpfloadoracleblob. 2. Now, we ' re still using database from the last tutorial. So, you don ' t need a new table or something. Modify your window to become like picture below.
I know most of you is lazy, so copy the XAML code below:
Look at the XAML code and you'll see some{binding}things. Wanna know about it? Then googling it
3. Okay, let's get into the logic. Here is the code of need to load image from database to WPF image control
Using system.windows;using system.data.oracleclient;using system.data;namespace wpfloadoracleblob{////// Interaction logic for Window1.xaml///public partial class Window1:window {public Window1 () { Initializeco Mponent (); } private void Window_Loaded (object sender, RoutedEventArgs e) { OracleConnection conn = new OracleConnection ( " Data source=localhost;" + "Persist Security info=true;" + "User id=c07; password=c07; Unicode=true "); Conn. Open (); OracleDataAdapter ad = new OracleDataAdapter ( "Select ROWNUM, Gambar_bin from Gambar", conn); DataTable TB = new DataTable (); Ad. Fill (TB); Combobox1.datacontext = TB; Conn. Close (); } }}
The key is Incombobox1.datacontext = Tb;it means this comboBox1 Bind the data from Yourselectquery.
4. Now test your project and see the result of your work.
Okay, that's all I can tell you. If you had any questions just leave it to the comment.
Load Image from the Oracle BLOB into WPF Image Control