using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
public class MainClass
{
public static void Main()
{
SqlConnection imageConnection = new SqlConnection(@"data source = .\sqlexpress;integrated security = true;initial catalog = tempdb;");
SqlCommand imageCommand = new SqlCommand(@"select imagefile,imagedata from imagetable ",imageConnection);
imageConnection.Open();
SqlDataReader imageReader = imageCommand.ExecuteReader();
string imageFilename = (string) imageReader.GetValue(0);
byte[] imageBytes = (byte[]) imageReader.GetValue(1);
MemoryStream ms = new MemoryStream(imageBytes);
Bitmap bmap = new Bitmap(ms);
imageReader.Close();
imageConnection.Close();
}
}