반응형
// Put user code to initialize the page here
MemoryStream stream = new MemoryStream ();
SqlConnection connection = new SqlConnection (@"server=test;database=pub;uid=sa;pwd=1234");
try
{
connection.Open ();
SqlCommand command = new
SqlCommand ("select image from Image", connection);
byte[] image = (byte[]) command.ExecuteScalar ();
stream.Write (image, 0, image.Length);
Bitmap bitmap = new Bitmap (stream);
bitmap.Save (Response.OutputStream, ImageFormat.Jpg);
//또는 다른 스트림에 넣어서 image 객체로 보내거나 파일로 저장하여 사용한다.
}
finally
{
connection.Close ();
stream.Close ();
}
MemoryStream stream = new MemoryStream ();
SqlConnection connection = new SqlConnection (@"server=test;database=pub;uid=sa;pwd=1234");
try
{
connection.Open ();
SqlCommand command = new
SqlCommand ("select image from Image", connection);
byte[] image = (byte[]) command.ExecuteScalar ();
stream.Write (image, 0, image.Length);
Bitmap bitmap = new Bitmap (stream);
bitmap.Save (Response.OutputStream, ImageFormat.Jpg);
//또는 다른 스트림에 넣어서 image 객체로 보내거나 파일로 저장하여 사용한다.
}
finally
{
connection.Close ();
stream.Close ();
}
반응형