Click here to Skip to main content
Click here to Skip to main content

How To Bind Oracle BLOB Image into PictureBox

, 21 Sep 2012
Rate this:
Please Sign up or sign in to vote.
In my last tutorial (about bind oracle blob image in WPF), I showed you how to bind from Oracle BLOB into Image in WPF. But, there is a different trick if you use Windows Form Application (in this case, we’re using PictureBox component). There is nothing different in concept, but the problem is alwa
image
In my last tutorial (about bind oracle blob image in WPF), I showed you how to bind from Oracle BLOB into Image in WPF. But, there is a different trick if you use Windows Form Application (in this case, we’re using PictureBox component). There is nothing different in concept, but the problem is always the code. To save an image or picture you can use the same method. But, you need a trick to load it. Okay, now let me show you the trick.

1. Use the same database just like in my last tutorial. Now, make a new Windows Form Application and name it with WinFormLoadOracleBlob. Add a combo box and a picture box show the form should be like picture below:
image

2. Now, double click on Form and you’ll see Form1_Load function. Modify the code like this:
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace WinFormLoadOracleBlob
{
 public partial class Form1 : Form
 {
  public Form1()
  {
   InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs 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);
   //bind datatable to comboBox1.DataSource
   comboBox1.DataSource = tb;
   comboBox1.DisplayMember = "ROWNUM";
   //bind pciture to comboBox1.DataSource
   //and enable formatting to true
   pictureBox1.DataBindings.Add("Image", 
   comboBox1.DataSource, 
   "GAMBAR_BIN", true);
   conn.Close();
  }
 }
}

3. Now, test your application and see the result!

image

Okay, that’s all I got for this. Hope this’ll help you all. 


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Junian Triajianto
Software Developer
Indonesia Indonesia
Just an ordinary geek.
 
For more information visit my blogs:
Junian Legacy
Kodefun, learning by coding
Follow on   Twitter   Google+

Comments and Discussions

 
GeneralMy vote of 4 PinprofessionalAmir Farid7-Oct-13 1:11 
GeneralMy vote of 3 PinmemberKlaus Luedenscheidt21-Sep-12 17:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 21 Sep 2012
Article Copyright 2012 by Junian Triajianto
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid