how to convert BLOB DB field to readable format (text)

  • Thread starter Thread starter Serge Klokov
  • Start date Start date
S

Serge Klokov

Hello!

I have a Oracle table with a BLOB field.
Each field is actually a simple text file of several lines.
How to get this BLOB fields in readable format?

I tryied something like
row["DOCLIST"].ToString()

But it give result "System.Byte" instead of actual text...

Thank you,
 
I have a Oracle table with a BLOB field.
Each field is actually a simple text file of several lines.
How to get this BLOB fields in readable format?

I tryied something like
row["DOCLIST"].ToString()

But it give result "System.Byte" instead of actual text...

look at the GetString(...) method in the Encoding class. this will work for
you.

Regards,
Wiktor Zychla
 
It doesn't work, or i'm doing something wrong: Cannot implicitly convert
type 'object' to 'byte[]'

againg: I have record: row["DOCLIST"]

If i would save this record from Oracle to disc i will have plaint text
file:

one
two
three


in C#
String typ = row["DOCLIST"].GetType().ToString(); //return System.Byte[]

but all this doesn't work:
System.Byte[] sb = row["DOCLIST"]; //Error: Cannot implicitly convert type
'object' to 'byte[]'
String s = System.Text.Encoding.UTF8.GetString((row["DOCLIST"])); //Error:
Cannot implicitly convert type 'object' to 'byte[]'
String s2 =
System.Text.Encoding.UTF8.GetString(row["PACKAGENAME"].ToString()); //Error:
Cannot implicitly convert type 'object' to 'byte[]'


I have a Oracle table with a BLOB field.
Each field is actually a simple text file of several lines.
How to get this BLOB fields in readable format?

I tryied something like
row["DOCLIST"].ToString()

But it give result "System.Byte" instead of actual text...

look at the GetString(...) method in the Encoding class. this will work
for
 
This is working:

Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(row["DOCLIST"]);
String s = System.Text.Encoding.UTF8.GetString(byteBLOBData);

Tnx for your help.
 
Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(row["DOCLIST"]);
String s = System.Text.Encoding.UTF8.GetString(byteBLOBData);

then this should work also:

byte[] byteBLOBData = (Byte[])(row["DOCLIST"]);
String s = System.Text.Encoding.UTF8.GetString(byteBLOBData);
 
Back
Top