Thanks for your reply.
The code is very simple, as follows:
===========================================
public byte[] GenerateXMLStringAndBuffer(string valueString)
{
byte[] theBytes=ConvertStringToBytes(valueString);
//string stringConverted=ConvertBytesToString(theBytes);//commented
return theBytes;
}
The problems is: When I call the above method, and stored the bytes(counts
5563 bytes) returned into a Image(BLOB) data field of database. When I
retrive the data back, I got (5563+28) bytes with 28 bytes at the beginning,
which contains invalid characters such as 0x01, \0, and lead to the
deserialization(ConvertBytesToString) to fail.
However, if I directly call the deserialization(ConvertBytesToString) just
after the serialization as shown in the above method. It returns the correct
string.
Therefore, the problem should be in the additional 28 bytes ahead of the
normal data cause the problem. I can manually resolve this problem, but I am
not sure whether this can be a formal way, that is, I would like to have some
theoratical support for the solution adpoted.
Any suggestions?
===========================================
public static byte[] ConvertStringToBytes(string StringToBeSerialized)
{
byte[] theBytes=System.Text.Encoding.ASCII.GetBytes(Strin gToBeSerialized);
return theBytes;
}
public static string ConvertBytesToString(byte[] theBuffer)
{
string tempString=System.Text.Encoding.ASCII.GetString(th eBuffer);
return tempString.Trim(new char[] { '\0'});
}
==========================================
"rviray" wrote:
can you provide the code that converts your object (image, long string,
etc.) prior to the inserting into the db...can you post it?
I have experience with stuffing images, large txt fiels, large XML docs
into various SQL fields and don't remember coming accross this issue...
:confused:
Also, have you explored the Binary Field type (assuming we are talking
SQL), I tend to use an Image Field with just images, but for scenarios
when you don't know what your gonna hold...BLOB fields do the trick...
--
rviray
------------------------------------------------------------------------
rviray's Profile: http://www.msusenet.com/member.php?userid=4211
View this thread: http://www.msusenet.com/t-1871084574