|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reading Text datatype into a byte ArrayHi,
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 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 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! Show quoteHide quote "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 > >
Other interesting topics
Strange behaviour with .NET apps with Framework 2.0
Deserialization constructor Exception with HttpWebRequest.GetResponse Writing a windows service with a socket interface. Dynamicly refrence a .NET DLL State of Objects... limits for filestreams (C#) Command to terminate execution Getting things into an array of bytes formatting numbers |
|||||||||||||||||||||||