0

我有一个系统,我通过仓鼠捕获用户的生物特征并在 a 中获取生物特征模板WideString,我的问题是在数据库中的字符串的记录和检索中,必须缺少字符串的某些部分,看看保存和检索生物识别模板的代码:

保存:

我通过变量获得了生物识别阅读器的字符串模板_Template

var
  _Template: WideString;

  function StrToMemoryStream(SourceString: WideString): TMemoryStream;
  begin
    Result := TMemoryStream.Create;
    Result.WriteBuffer(Pointer(SourceString)^, Length(SourceString));
    Result.Position := 0;
    SetLength(SourceString, Result.Size);
    Result.ReadBuffer(Pointer(SourceString)^, Result.Size);
  end;
  // getting biometric string
  _Template := GetStringBiometric;
  // saving into database
  ADOQuery1.Open;
  ADOQuery1.Edit;
  TBlobField(ADOQuery1.FieldByName('CLD_TEMPLATE1')).LoadFromStream(StrToMemoryStream(_Template));
    ADOQuery1.Post;

之后,获取数据库的值

var
  _Template: WideString;

  function GetStrToStream(Field: TField): WideString;
  var
    Stream: TMemoryStream;
  begin
    Result := '';
    Stream := TMemoryStream.Create;
    try
      TBlobField(Field).SaveToStream(Stream);
      Stream.Position := 0;
      SetLength(Result, Stream.Size);
      Stream.ReadBuffer(Pointer(Result)^, Stream.Size);
    finally
      FreeAndNil(Stream);
    end;
  end;

  ADOQuery1.Open;
  _Template := GetStrToStream(ADOQuery1.FieldByName('CLD_TEMPLATE1'));
  ADOQuery1.Close;

返回模板后没有与生物识别模板匹配,这是在某些转换中失去了一些价值?我是初学者编程WideString数据和TMemoryStream类,SQL Server 数据库中的列类型为Image.

谢谢你,

4

0 回答 0