GetBinaryStream Equivalent

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hi All,

I am really stuck and hope someone can come to my rescue. I need to be able to call

dataReader.GetBytes for a column which is defined as a varchar2.

When I try to do this I get an InvalidCast Exception. Why do I need to do this?

The drivers for Oracle or somewhere in between is encoding the string that is stored in the varchar2 column and I need to get this string in it's raw form. I am unable to change the database column type for politcal reasons so somehow I need to get the raw bytes in that column.

Java has the ability to do this by calling getBytes or getBinaryStream from their ResultSet object which is equivalent to .NET's DataReader/OracleDataReader object.

My hope is that there is some way to get these bytes with the .NET framework? Anyone?

Please help.

Thanks,

Dave
 
byte[] result = System.Text.Encoding.Default.GetBytes
(dataReader.GetString (0));

NOTE: you can use UTF8 or any encoding u like to get the bytes.

NuTcAsE
 
Hello NuTcAsE,

Hello and thanks for the advise, unfortunatly this did not work for me as the call to GetString corrupted/encoded the string. I did find a solution though. In my query to the database I added RAWTOHEX(TO_MULTI_BYTE(NAME)) AS RAWNAME and this got me what I needed. Non-encoded stream.

Cheers,

Dave
 
Back
Top