Showing posts with label signature. Show all posts
Showing posts with label signature. Show all posts

Tuesday, March 27, 2012

Converting bytes [] to an SQL CE 3 image type to store

Hi,

I was wondering if anyone knows how to convert an array of bytes to an SQL CE 3 image type and vice versa.

I am using the SDF Signature control and I would like to store the signature as an Image. It needs to be an image so it can be synced with a desktop access 2003 database.

Cheers

Simon

I have got around this by changing the Image type to nText then converted the byte array to a base64 string and this works a treat.

Cheers

Simon.

|||

Better way to do it would be to create memory stream from byte array from SQL and pass it to bitmap constructor:

Bitmap bmp = new Bitmap(new MemoryStream(byteArrayFromSqlCe));

Sunday, February 19, 2012

Convert HEX to Text

I have an image data type in a table (it is a digital signature) and one of my users wants me to search the image data and see how many people have a certain attribute in their digital signature. I know the image data is HEX, but how, in query analyzer, can I view it as the XML digital signature data that it really is? So, how can I convert hex to text in sql server?

hi
you can use this function:

CREATE function HEXTODEC(@.s VARCHAR(255) )
--Converts an hexadecimal number to decimal.
returns int
as
BEGIN
DECLARE @.i int, @.temp char(1), @.result int
SELECT @.i=1
SELECT @.result=0
WHILE (@.i<=LEN(@.s))
BEGIN
SELECT @.temp=UPPER(SUBSTRING(@.s,@.i,1))
IF (@.temp>='0') AND (@.temp<='9')
SELECT @.result=@.result+ (ASCII(@.temp)-48)*POWER(16,LEN(@.s)-@.i)
ELSE
IF (@.temp>='A') AND (@.temp<='F')
SELECT @.result=@.result+ (ASCII(@.temp)-55)*POWER(16,LEN(@.s)-@.i)
SELECT @.i=@.i+1
END
return @.result
END

good luck

|||

Thanks, but that doesn't help. I had actually found that on a Google search, but it only works for numbers, when the data is really XML.

I did, however, find that SQL Manager 2005 for SQL Server can show the image field as the XML that it really is, so I was able to kind of get the data out that I needed. A bit of a convoluted way, and I only have a trial version of SQL Manager 2005 for SQL Server, but it got me the results I needed.