Retrieving LONG RAW Data (Bytes) from EnterpriseLibrary

I have a problem getting image byte data from oracle. reader("image") always returns 0 lengths. Is they a workaround? If I used oledb , then it worked, but did not work with 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); } } 
+8
c # oracle oracle11g enterprise-library
source share
2 answers

Try using OracleDataReader and OracleBlob as a data type:

 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); } } } } 
0
source share

If the ExecuteNonQuery method returns 0, then one of the reasons may be quite obvious that your query, where the sentence does not match any row in the table.

I got this stream from the internet, it could help

Another case that happened to me was that when I used the Enterprise library Data Application data block to execute the Update SQL query using the ExecuteNonQuery method, I passed the input parameters using the AddInParameter method of the Database object so that it did not match the order of the parameters in my sql update, especially the input parameter in where where.So, as soon as I passed the where where parameter using AddInParameter at the end of the AddInParameter heap, the problem was resolved immediately.

0
source share

All Articles