使用微软企业库获取sql varbinary记录
我有这行代码
byte[] field1 = (reader.GetSqlBinary(reader.GetOrdinal("Field1")).Value;
,它是一个 SqlDataReader
我正在尝试将代码转换为使用企业库数据访问块,但无法弄清楚如何获取 byte[]
使用IDataReader
。
我仔细浏览了 MS 文档,但没有找到任何有帮助的内容。
I have this line of code
byte[] field1 = (reader.GetSqlBinary(reader.GetOrdinal("Field1")).Value;
which is a SqlDataReader
I am trying to convert the code to use the enterprise library data access block but cant figure out how to get a byte[]
using the IDataReader
.
I've had a good look through the MS docs but failed to find anything that helped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要尝试的第一件事是(其中
i
是reader.GetOrdinal("Field1")
):如果失败,也许:
另请注意,该行为可能 根据是否指定 CommandBehavior.SequentialAccess 略有变化。
The first thing I would try is (where
i
isreader.GetOrdinal("Field1")
):If that fails, perhaps:
Note also that the behaviour may change slightly depending on whether
CommandBehavior.SequentialAccess
is specified.