Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Reading Text datatype into a byte Array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debu Das - 18 Feb 2005 11:07 GMT
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
Cor Ligthert - 18 Feb 2005 12:30 GMT
Debu,

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


I hope this helps?

Cor
Debu - 18 Feb 2005 12:47 GMT
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
madfiddler - 24 May 2005 17:18 GMT
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!

> Hi Cor,
>
[quoted text clipped - 4 lines]
>
> Debu

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.