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 System.Data.SqlClient;
using System.IO;
using System.Drawing.Imaging;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection("Data Source=VARNAR12;Initial Catalog=master;Integrated Security=True");
SqlCommand com = new SqlCommand();
static MemoryStream ms;
SqlDataReader dr;
public Form1()
{
InitializeComponent();
SqlCommand com = new SqlCommand("SELECT picid, " + "picdata FROM pic ORDER BY picid", con);
dr = default(SqlDataReader);
con.Open();
dr = com.ExecuteReader();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
<pre lang="cs">if (dr.Read())
{
label1.Text = dr[0].ToString();
byte[] pic1 = new byte[dr.GetBytes(1, 0, null, 0, int.MaxValue)];
dr.GetBytes(1, 0, pic1, 0, pic1.Length);
MemoryStream stmdata = new MemoryStream(pic1);
pictureBox1.Image = Image.FromStream(stmdata);
}
dr.Close();
}
}
}