Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Thanks in advance. Can anybody help to solve my problem which is described below.

I did a socket application which is receiving data from a vehicle tracking example as follows:

Example- %%D1,100,0,0004[data...][0d0a]

Head -   %%D1
Amount of data package -100
The data package No.  - 0
Data Length -1024  (0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)

data- Original Picture data -1024(maximum)
Tail -0x0d0a
Data in hex

From the above example, I want to extract picture data and need to store into the SQL table. SQL table columname is image and datatype is also image. After that, I want to display this image column to an aspx page.

expecting help asap.
Updated 23-Aug-10 8:08am

1 solution

If I got that right, image data is in Hex format, right? So we can put the data in a bytearray, and then save it to database.

Once you extracted data and saved it to a bytearray, the rest will be easy. Here is a good example of how to do that:
Converting Hexadecimal String to/from Byte Array in C#[^].

You need to create a MemoryStream, see this:[^].

Then store it in database, see this:[^].



Share this answer
meenu s 22-Aug-10 18:16pm    
dear friend ,can u help me from the first step.
i wanted to extract picture data from that string and need to put in a byte array.can u explain the code here for that?

dim str as string="%%D1,100,0,0004[data...][0d0a]"
The Zetta 23-Aug-10 9:42am    
Hi. please give me an actual string, so I can write the code for you. I mean, fill the data part. and, are brackets in the string? or just used to show limits?
meenu s 23-Aug-10 12:47pm    
dear friend,bracket is not thre in the part contains the information in hex (1024(maximum)).string always contains 0d0a which is the tail of the string.
The Zetta 23-Aug-10 12:52pm    
OK, it is getting clearer. now let me now, % and comma are there? or not? header is always D110000004? or at least, its length is always 10 characters?
meenu s 25-Aug-10 0:16am    
comma and %% is thre always.which is seperating the data.
0004 means Data Length -1024(picture data)
0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900