Load Image from the Oracle BLOB into WPF Image Control

Source: Internet
Author: User
Tags oracleconnection

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.