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;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
MySqlConnection connection = new MySqlConnection("");
MySqlCommand command;
MySqlDataAdapter da;
private void button1_Click(object sender, EventArgs e)
{
string query = "select * from files where ID= '" + textBoxID.Text + "'";
command = new MySqlCommand(query, connection);
da = new MySqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
textBoxID.Text = dt.Rows[0][0].ToString();
//set image from mysql database to pictureBox
byte[] img = (byte[])dt.Rows[0][3];
MemoryStream ms = new MemoryStream(img);
pictureBox1.Image = Image.FromStream(ms);
da.Dispose();
}
รบกวนช่วยทีนะครับ
}
}
Tag : .NET, C#, VS 2010 (.NET 4.x), VS 2012 (.NET 4.x), C