asp二进制mysql_asp.net读取显示二进制图片从MySQL数据库

本文介绍了一个ashx页面从数据库读取图片的问题,该方法仅能读取出第一张图片,未能显示所有WishImage。寻求解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ashx页面MemoryStreamstream=newMemoryStream();SqlConnectionconnection=newSqlConnection("省略。。。");try{connection.Open();SqlCommandcommand=newSqlCommand("selectWishImage...

ashx页面

MemoryStream stream = new MemoryStream();

SqlConnection connection = new SqlConnection("省略。。。");

try

{

connection.Open();

SqlCommand command = new SqlCommand("select WishImage from Wish ", connection);

byte[] image = (byte[])command.ExecuteScalar();

stream.Write(image, 0, image.Length);

Bitmap bitmap = new Bitmap(stream);

context.Response.ContentType = "image/jpeg";

bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

}

finally

{

connection.Close();

stream.Close();

}

aspx页面

xx.ashx

用了以上方法,只能读取到数据库中的第一张图片,不能显示所有的WishImage

求大神帮忙修改一下

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值