Jumat, 10 April 2015

C# - How To Retrieve Image From MySQL Database To dataGridView Using C#

C# - How To Display Image From MySQL Database To dataGridView In C#

__________________________________________________________________________

In This C# Tutorial We Will See How To  Get Pictures From MySQL database
 To DataGridView In CSharp Programming Language .


Project Source Code:







using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace WindowsFormsApplication1
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }
        MySqlConnection con = new MySqlConnection("datasource=localhost;port=3306;Initial Catalog='DB_Images';username=root;password=");
        MySqlCommand command;
        MySqlDataAdapter da;
        private void Form4_Load(object sender, EventArgs e)
        {
            string query = "select * from myimages";
            command = new MySqlCommand(query, con);
            da = new MySqlDataAdapter(command);
            DataTable dt = new DataTable();

            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView1.RowTemplate.Height = 120;
            dataGridView1.AllowUserToAddRows = false;

            da.Fill(dt);

            dataGridView1.DataSource = dt;

            DataGridViewImageColumn image = new DataGridViewImageColumn();
            image = (DataGridViewImageColumn)dataGridView1.Columns[3];
            image.ImageLayout = DataGridViewImageCellLayout.Stretch;
            da.Dispose();
        }
    }
}
/////////////////////  END
///////////////OUTPUT:
  
    


Display Image From MySQL Database To dataGridView In C#
Display Image From Mysql Database To dataGridView 


Bagikan

Jangan lewatkan

C# - How To Retrieve Image From MySQL Database To dataGridView Using C#
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.