473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem with Image data type, serialization.

I have a field set to Image data type, and store a long string(possible other
objects)into it with size 5663, and returned with 5663+28 bytes.

These strings wil be deserialized after retrieving. However failde because
the bytes seems to include some extra bytes with \0 and 0x01 and have 28 more
bytes ahead of the original string.

How could I deal with it? Just remove the first 28 bytes? It this method
formal? I had thought the returned bytes should have the same size with the
one I stored into, it seems not, am I right?

Also, the select statement on a database with Image data type doesn't return
the actual data, but the 16 bit pointers. Any explanation for this?

Thanks.

Sep 27 '05 #1
2 1756

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

Sep 28 '05 #2
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

Sep 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
5
by: sdettmers | last post by:
Hi, Database: SQL Server Session: SQL Server Language: C# Application: ASP.Net I have created a login page which attempts to retrieve the users record from the database and I...
2
by: zhaounknown | last post by:
I have a field set to Image data type, and store a long string(possible other objects)into it with size 5663, and returned with 5663+28 bytes. These strings wil be deserialized after retrieving....
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
0
by: nicomp | last post by:
I created a Web Service: I imported System.Data.SqlClient so I could access SQL server tables programmatically. The web service builds and deploys with no problems. When I try to add the...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.