获得使用SqlDataReader的二进制数据

编程入门 行业动态 更新时间:2024-10-28 12:25:06
本文介绍了获得使用SqlDataReader的二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个名为一滴表(ID(INT),数据(图像))。我需要使用SqlDataReader对象来获取图像数据。注意,我不想Response.Binarywrite()的数据到浏览器。我只需要二进制数据为byte []的使用相同的一些内部操作。只有这样我能想到的是越来越ID使用SqlDataReader的和再次使用SqlCommand.ExecuteScalar()来获取作为字节[]为给定ID。我可以只使用SqlDataReader的(SqlCommand.ExecuteReader)来获取图像数据的byte []?我缺少什么?

I have a table named Blob (Id (int), Data (Image)). I need to use SqlDataReader to get that image data. Note that I dont want to Response.Binarywrite() the data to the browser. I just need that binary data as byte[] to use the same for some internal operations. Only way I can think of is getting id using SqlDataReader and the again use SqlCommand.ExecuteScalar() to get that as byte[] for a given id. Can I use just the SqlDataReader (SqlCommand.ExecuteReader) to get that image data as byte[]? Am I missing anything?

推荐答案

您应该可以用得到它:(字节[])reader.Items [数据] 。

You should be able to get it via: (byte[])reader.Items["Data"].

另外请注意,图片数据类型是去precated,并且将在SQL Server的未来版本中删除;使用 VARBINARY(最大)代替。

Also note that the image data type is deprecated, and will be removed in a future version of SQL Server; use varbinary(max) instead.

更多推荐

获得使用SqlDataReader的二进制数据

本文发布于:2023-07-26 09:23:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:二进制数   SqlDataReader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!