当前代码看起来或多或少如下:
DataTable table = new DataTable(); sqlDataAdapter adapter = new sqlDataAdapter(commandText,connectionString); adapter.Fill(table); DaTarow row = table.Rows[0]; byte[] imageData = row[0] as byte[]; if(imageData != null) { Response.Clear(); Response.BinaryWrite(imageData); Response.End(); }
感谢提前 – 任何帮助是赞赏.
解决方法
SqlDataReader
打开的
SqlDataReader
:
SequentialAccess Provides a way for
the DataReader to handle rows that
contain columns with large binary
values. Rather than loading the entire
row,SequentialAccess enables the
DataReader to load data as a stream.
You can then use the GetBytes or
GetChars method to specify a byte
location to start the read operation,
and a limited buffer size for the data
being returned.
链接的文章提供了用于创建由sqlDataReader支持的流的完整代码,您可以简单地使用Stream.CopyTo
(HttpResponse.OutputStream)
,或者如果您还没有.Net 4.0,则使用byte []块复制.
该后续文章解释了how to use a FILESTREAM column for efficient streaming of large VARBINARY data进出数据库.
原文地址:https://www.jb51.cc/csharp/97245.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。