本人想实现从SQL数据库里面读取图片数据,然后显示在网页的IMAGE控件里面,在网上找到了如下代码:
MemoryStream stream = new MemoryStream();
        SqlConnection connection = new
        SqlConnection(@"Data Source=TEMPEL-D8B2F171;Initial Catalog=DataSource;User ID=sa;Password=sa");
        try
        {
            connection.Open();
            SqlCommand command = new
            SqlCommand("select photos from  UserInfor where UserName='tt'", connection);
            byte[] image = (byte[])command.ExecuteScalar();
            stream.Write(image, 0, image.Length);
            Bitmap bitmap = new Bitmap(stream);
            Response.ContentType = "image/Jpeg";
            bitmap.Save(Response.OutputStream, ImageFormat.Jpeg  );
           // bitmap.SaveAdd(Image1, ImageFormat.Gif);
            
            
        }
        finally
        {
            connection.Close();
            stream.Close();
        }运行结果:打开新页并显示图片,不知道如何实现打开指定页面并显示在IMAGE控件中,
初学ASP,请各位给出详细解决办法,谢谢了