我有一个有趣的问题。我必须拍摄保存在Sqlite3数据库中的签名图像。
当您在Sqlite3数据库上查看已保存的签名时,它是一个签名。数据库上载到具有MSSQL Server的服务器,然后MSSQL Server读取签名图像。不幸的是,这个图像在服务器上看起来完全是黑色的,并且它返回相同。 db管理员说数据似乎是垃圾(包括unicode字符)。
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.
我的猜测是unicode是负责任的。不确定如何解决此问题。
数据连接组件是TSQLConnection。查询组件是TSQLQuery。我正在使用XE5构建Firemonkey iOS移动应用程序。
这是我的代码。感谢任何帮助。
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;