【发布时间】:2015-03-25 17:48:27
【问题描述】:
我正在尝试检索在 Oracle 数据库中存储为 BLOB 的证书,但我不断得到一个空字节数组。这是一个代码sn-p:
OracleCommand command = new OracleCommand(QUERY_GETURLS, connection);
OracleDataReader reader = null;
try
{
connection.Open();
reader = command.ExecuteReader();
while (reader.Read())
{
string organization = reader["Organization"].ToString();
string type = reader["Type"].ToString();
string url = reader["DestinationUrl"].ToString();
byte[] certificate = (byte[])reader["Certificate"];
组织、类型和 URL 可以正常返回,但证书字段总是返回一个空字节数组。如果我手动对数据库运行相同的查询,则会返回 BLOB 列。列数据类型是 LONG RAW,我使用的是 ODP.NET。
【问题讨论】:
-
你看过这里的 OracleDataType 映射吗msdn.microsoft.com/en-us/library/yk72thhd%28v=vs.110%29.aspx
-
OracleDataReader reader也许BinaryReader会起作用,或者看看这个链接devart.com/dotconnect/oracle/articles/lob.html -
@MethodMan 谢谢你。我在这里找到了该页面的 ODP.NET 版本docs.oracle.com/cd/B28359_01/win.111/b28375/featTypes.htm,他们声明如果我的列类型是 LONG RAW,我需要使用 OracleBinary。我想我需要将列更改为 BLOB 并使用字节数组。
-
这很好,假设您可以使用已加载的数据更改列的数据类型..您应该可以这样做..很高兴您能够找到可行的解决方案
"+1"