SQL Veritabanından Binary Resim Okuma

SQL Veritabanından Binary Resim Okuma için tıklayınız.

resim-cek1

 

 

 

 

 

 

 

 

 

resim-cek2

 

 

 

 

 

 

 

 

 

resim-veri

 

 

 

 

C# Kodları :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;

namespace resim
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection(“Data Source=.\\SQLEXPRESS; Initial Catalog=resim; Integrated Security=true;”);
private void button1_Click(object sender, EventArgs e)
{
MemoryStream ms = new MemoryStream();
conn.Open();
string sorgu = “select * from bilgi where id='”+textBox1.Text+”‘”;
SqlCommand cmd = new SqlCommand(sorgu, conn);
try
{
SqlDataReader rdr = cmd.ExecuteReader();
byte[] by = null;
while (rdr.Read())
{
by = (byte[])rdr[3];
label2.Text = rdr[1].ToString();
label3.Text = rdr[2].ToString();
}
ms.Write(by, 0, by.Length);
Bitmap bmp = new Bitmap(ms);
pictureBox1.Image = bmp;

}
catch (Exception e1)
{
MessageBox.Show(“Exception:” + e1.ToString());
}

}
}
}

admin