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

Re: Reading Text datatype into a byte Array by Cor

Cor
Fri Feb 18 06:30:17 CST 2005

Debu,

Have a look at this encoding
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclassgetbytestopic2.asp

I hope this helps?

Cor



Re: Reading Text datatype into a byte Array by Debu

Debu
Fri Feb 18 06:47:37 CST 2005

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


Re: Reading Text datatype into a byte Array by madfiddler

madfiddler
Tue May 24 11:18:53 CDT 2005

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!





"Debu" wrote:

> 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
>
>