logo       

RE: Extracting a System.Byte[ ] via C#: msg#00035

Subject: RE: Extracting a System.Byte[ ] via C#
Keith,

Have you seen this MSDN article:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconobtainingblobvaluesfromdatabase.asp

The trick is to use the GetBytes method on the datareader to pull out the
blob, and store it into an array (or memory stream or something). Once
you've got it into the array of bytes, you can use one of the Encoding
classes or your hexstring function or whatever to convert that array back
into a string.

-Chris

-----Original Message-----
From: Keith R. Pinster [mailto:keith.pinster@xxxxxxxxx] 
Sent: Tuesday, December 07, 2004 1:54 PM
To: padnug@xxxxxxxxxxxxxxx
Subject: [padnug] Extracting a System.Byte[ ] via C#



Can someone give me a direction in researching how to convert a 
System.Byte[] data type into raw data (basically, a text string) 
using a DataReader in C#?

I'm pulling data out of a FoxPro database.  One of the tables has a 
column which is a bitmap type (holding a signature file).  I've tried 
just using 

string myText = myReader.GetValue(CurrentField);
string myText = Convert.ToBase64String(myReader.GetValue
(CurrentField))
string myText = myReader.GetValue(CurrentField).ToString();
string myText = myReader.GetString(CurrentField);

I've also tried to run it through the function

private static string ToHexString(byte[] bytes) 
{
        char[] chars = new char[bytes.Length * 2];
        for (int i = 0; i < bytes.Length; i++) 
        {
                int b = bytes[i];
                chars[i * 2] = hexDigits[b >> 4];
                chars[i * 2 + 1] = hexDigits[b & 0xF];
        }
        return new string(chars);
}

which is an example in the documentation, but can't figure out how to 
convert the CurrentField value into an array of bytes.  

I'm just lost here.  Can someone give me a link to an article that 
might help ow something?

Thanks






 
Yahoo! Groups Links



 







------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~-> 

 


<Prev in Thread] Current Thread [Next in Thread>