473,811 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1788

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[] GenerateXMLStri ngAndBuffer(str ing valueString)
{
byte[] theBytes=Conver tStringToBytes( valueString);
//string stringConverted =ConvertBytesTo String(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 (ConvertBytesTo String) to fail.
However, if I directly call the deserialization (ConvertBytesTo String) 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[] ConvertStringTo Bytes(string StringToBeSeria lized)
{
byte[] theBytes=System .Text.Encoding. ASCII.GetBytes( StringToBeSeria lized);
return theBytes;
}

public static string ConvertBytesToS tring(byte[] theBuffer)
{
string tempString=Syst em.Text.Encodin g.ASCII.GetStri ng(theBuffer);
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
2317
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 http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl AmazonWebService.com.amazon.webservices.Item As you can see from the code snippets below it has public member variables rather than public Properties. When I use <%# DataBinder.Eval(Container.DataItem, "ASIN") %> syntax in...
5
5695
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 store the validated users DataRow into Session which is in SQLServer. I have listed the error below for you to
2
246
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. 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...
2
2761
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" and return a complex type "FieldSearchResult". The error message as following : "Cannot assign object of type System.String to an object of type System.String. There is an error in XML document (23, 97)." By the way,I hava written a client in Java...
5
19604
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 having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
1
5555
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 other properties... bool error; string lastError; My whole class looks like this... using System;
4
7161
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 serialize the data to put the array into the cookie. That part of my code is working just fine and displaying fine. The problem I’m having is when I try to unserialize and display; the data does not appear. If I remove my unserialize command line (see...
0
2062
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 corresponding Web Reference to the Web Site project I get the error listed below. I am able to create other Web Services on the same server and I am able to add Web Referneces to them. I have narrowed it down to the "Imports System.Data.SqlClient"...
11
3063
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
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.