Reading Text datatype into a byte Array

  • Thread starter Thread starter Debu Das
  • Start date Start date
D

Debu Das

Hi,

I am populating a records fetched from a select query in
OleDbDataReader. The datbase is MS Access, The datatype of the select
query column is Text. I want to read the data as Byte array instead of
string as Reading it into a string causes it to be converted to
Unicode which is do not want.

Anybody is aware of some sites from where i can get valuable
information or some sample project please do let me know about it.

Any information provided will be greatly appreciated.

Thanks in advance,

Debu
 
Hi Cor,

I want to read it as a byte array, not the way you thought of i.e.
reading it as a string then converting it to byte array.

Regards,

Debu
 
Debu

I understand the issue you have is that the source data is a string which is
a single-byte character set. But as soon as you read this into a string
variable in .NET it becomes unicode.

I'm not sure if you can use the OleDbDataReader to effectively read in a
byte mode rather than as string data. If you can then this is obviously the
way to go.

You should also be aware that you can convert from one code page to another
using the Encoding class, which should get around the problem you are having.

Dim UnicodeString as String = "TEST"
Dim Enc As Encoding
Dim CodePage1252_ByteArray as Byte() =
Enc.GetEncoding(1252).GetBytes(UnicodeString)

as well as the GetEncoding method you may also find useful the Convert
method amongst others!


Hope that helps!
 
Back
Top