Saved Sqlite Image Appears Totally Black On Uploaded Server Database

  

I have an interesting problem. I have to take a signature image that is saved in Sqlite3 database.

When you view the saved signature on the Sqlite3 database it is a signature. The database is uploaded to a server that has MSSQL Server which then reads the signature image. Unfortunately this image appears totally black on the server and it comes back the same. The db administrator says that the data appears to be garbage (includes unicode characters).

Example of the image data is:
Sent Data: Tried to include but unfortunately it will not show unicode. It is thousands of bytes long.
Returned Data: *System.Byte[]* <<and that is it – 26 bytes long.

My guess is that the unicode is responsible. Not sure how to resolve this issue.

The data connection component is TSQLConnection. The query component is TSQLQuery. I am using XE5 building a Firemonkey iOS mobile application.

Here is my code. Appreciate any help.

function SaveSig: boolean;
var
fStream: TMemoryStream;
begin
Result := False;
fStream := TMemoryStream.Create;
try
try
fStream.Seek(0, soFromBeginning);
fStream.Position := 0;
if Assigned(imgSig) then
begin
imgSig.Bitmap.SaveToStream(fStream);
Result := SqlInsertSig(fStream);
end;
except
on e: Exception do
ShowMessage(ERROR_BITMAP + e.Message);
end;
finally
if Assigned(fStream) then
FreeAndNil(fStream);
end;
end;

function SqlInsertSig(const ms: TMemoryStream): boolean;
begin
Result := False;
try
try
sq.Active := False;
sq.CommandText := ‘Insert Into Signatures (Id, Sig) Values (‘ +
QuotedStr(IntToStr(Id)) + ‘, :sig)’;
sq.Params.ParamByName(‘sig’).LoadFromStream(ms, ftBlob);
Result := (sq.ExecSQL > 0);
except
on e: Exception do
MessageDlg(e.Message, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0);
end;
finally
sq.Active := False;
end;
end;

Comments are closed.