从EnterpriseLibrary获取LONG RAW数据(字节)

时间:2017-07-30 09:58:28

标签: c# oracle oracle11g enterprise-library

我从oracle获取图像字节数据时遇到问题。 oledb始终返回0长度。他们的任何解决方法?如果我使用Microsoft EnterpriseLibrary,那么它可以使用using (IDataReader reader = ExecuteNonQueryOracle(Query)) { while (reader.Read) { dict("image") = reader("image"); } } public object ExecuteNonQueryOracle(string Query) { using (dbCommand == CurrentDatabase.GetSqlStringCommand(Query)) { dbCommand.CommandType = CommandType.Text; return CurrentDatabase.ExecuteReader(dbCommand); } }

ContentResolver cr = mContext.getContentResolver();
String mime = cr.getType(uri);

2 个答案:

答案 0 :(得分:1)

如果ExecuteNonQuery方法返回0,那么一个原因很明显,你的查询的where子句与表中的任何行都不匹配。

我从网上获得了这个帖子,这可能有帮助

与我发生的另一个案例是,当我使用Enterprise Library Data Application块使用ExecuteNonQuery方法执行Update sql查询时,我使用Database对象的AddInParameter方法按顺序传递输入参数,而不是与我的更新sql中的参数顺序,特别是where子句中的输入参数。一旦我在AddInParameter子句的末尾使用AddInParameter传入where子句参数,问题就立即解决了。

答案 1 :(得分:0)

尝试使用OracleDataReaderOracleBlob作为数据类型:

using (OracleDataReader reader = cmd.ExecuteReader())
{
   while (reader.Read())
      {
         if (!reader.IsDBNull(reader.GetOrdinal("FILE")))
               {
                 OracleBlob doc = reader.GetOracleBlob(reader.GetOrdinal("FILE"));
                  if (!doc.IsNull)
                   {
                       docBytes = new byte[doc.Length];
                       doc.Read(docBytes, 0, (int)doc.Length);
                   }
               } 
      }
}