Load Image from Oracle BLOB into WPF Image Control

來源:互聯網
上載者:User

標籤:java   aml   system   ons   gic   .net   apt   margin   ann   

 

Almost forgot. In my last tutorial, I tell you how to save Image / Photo into oracle database. But, there is another problem, how to read and view it from oracle database? Don’t worry, it’s very easy to do that. Just follow these steps and you’ll able to load Image from oracle database. And one thing, I’m using DataBinding technique in this tutorial, so you have 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 you don’t know how). Name it WpfLoadOracleBlob. 2. Now, we’re still using database from the last tutorial. So, you don’t need to make a new table or something. Modify your window to become like picture below.

I know most of you are lazy, so copy the XAML code below:

Look at the xaml code, you’ll see some{Binding}things. You wanna know about it? Then Googling it 

 

3. Okay, let’s get into the logic. Here is the code you 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()  {   InitializeComponent();  }  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 that 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 have any questions just leave it to the comment.

Load Image from Oracle BLOB into WPF Image Control

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.