I found a bug, when i use a bold field to save by unidac driver, the result is wrong, this bug Appeared in the da 7.0.65.1067.By modifying the “uDACRLabsUtils.inc” file, I succeeded. Hope this problem can be corrected in the next version.
Best Regards!
procedure WriteCrLabsParamValues(InputParams : TDAParamCollection; OutputParams: TDAParams; IgnoreBlobType : boolean = false; AWideMemoAsWideString: Boolean = False);
var i : integer;
par : uDACore.TDAParam;
outpar : DBAccess.TDAParam;
blobtype : TFieldType;
b: TMemoryStream;
ws: UnicodeString;
//add by mqx
{$IFDEF DELPHI2009UP}
st: TROBinaryMemoryStream;
{$ENDIF}
begin
for i := 0 to (InputParams.Count-1) do begin
par := InputParams[i];
outpar := OutputParams.ParamByName(par.Name);
// If no blob type is specified, then gets the default field type.
// BlobType is only meaningful to Oracle. MSSQL works fine just setting the DataType
blobtype := BlobTypeMappings[par.BlobType];
if (blobtype=ftUnknown) then blobtype := DADataTypesMappings[par.DataType];
outpar.ParamType := TParamType(par.ParamType);
if par.DataType = datWideMemo then
outpar.DataType := ftWideString
else
outpar.DataType := DADataTypesMappings[par.DataType];
if VarIsNull(par.Value) then begin
outpar.Clear
end
else begin
case par.DataType of
datWideMemo: begin
if not AWideMemoAsWideString then
{$IFDEF DA_WideMemoSupport}
begin
b := TMemoryStream.Create;
try
ws := VarToWideStr(par.Value);
b.Write(pointer(ws)^, Length(ws)*SizeOf(WideChar));
b.position := 0;
outpar.LoadFromStream(b, ftWideMemo);
finally
b.Free;
end;
end
else
{$ENDIF}
begin
outpar.DataType := ftWideString ;
outpar.asWideString := par.Value;
end;
end;
datBlob : begin
{$IFDEF DELPHI2009UP}
// 修正Blob字段保存后不正确的Bug edit by mqx
st := TROBinaryMemoryStream.Create(VariantToAnsiString(par.Value));
try
outpar.LoadFromStream(st, outpar.DataType);
finally
st.Free;
end;
{$ELSE}
if VarIsArray(par.Value) then
outpar.AsAnsiString := VariantToAnsiString(par.Value)
else
outpar.Value := par.Value;
{$ENDIF}
// 以下为原代码
{if VarIsArray(par.Value) then
outpar.AsAnsiString := VariantToAnsiString(par.Value)
else
outpar.Value := par.Value;}
end;
datMemo : begin
outpar.DataType := ftMemo;
// Only happens with Oracle
if not IgnoreBlobType and (blobtype<>ftUnknown) then outpar.DataType := blobtype;
outpar.Value := par.Value;
end
else
outpar.Value := par.Value;
end; { case }
end;
end; { for }
end;