Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread I'm converting DBISAM 3 to DXE (Unicode)
Fri, Sep 16 2011 11:12 AMPermanent Link

Rolf Frei

eicom GmbH

I have converted DBISAM 3 to DXE and it works now very well so far I have
done tests, but I encountered one strange thing: Any TParam.AsString := 'XY'
gets set as unicode and not as AnsiString per default anymore. This was a
ugly break in D2010, which was a big fault in my opinion by Embarcadero.
This will break so much of code out in the world, as I can't believe they
have realy changed that. The problem is now with any DB-System who must use
AnsiString (BDE,DBISAM,..). As a result of that, all exisiting code must be
changed to AsAnsiString to get parameters working correct. TParam.AsString
was in D2009 still AnsiStrings and that should be still the default. It' s
so bad thing that Embarcadero has changed this in D2010+!

As of this problem I try to change the dbismatb.GetParamData so it will
automaticly convert the widestring ParamData to AnsiString. As a result of
this change, my version of this routine looks now so:

procedure GetParamData(Param: TParam; Buffer: Pointer);
var
 s: AnsiString;
begin
  with Param do
     begin
     if (DataType in [ftBlob..ftTypedBinary]) or
        ((DataType in [ftString,ftFixedChar]) and
         (Length(VarToStr(Value)) > MAX_FIELD_SIZE)) then
        begin
        with TQueryBlobParam(Buffer^) do
           begin
           BlobBuffer:=TRecordBuffer(PAnsiChar(VarToStr(Value)));
           BlobLength:=Length(VarToStr(Value));
           end;
        end
     else
     begin
        GetData(Buffer);
        {--- New code to convert the paramdata to ansistring if it is
widestring ---}
        if (DataType in [ftWideString,ftFixedWideChar]) then
        begin
          s := AnsiString(PChar(Buffer));
          StrCopy(PAnsiChar(Buffer), PAnsiChar(S));
        end;
        {--- End of Change ---}
     end;
  end;
end;

As DBISAM doesn't support native Unicode, I think it will be correct that
any widestring params should be convertet to AnsiString here. It works
perfectly as far I can see, but I'm not sure if there may be a problem with
it, which I can't see yet, as I have missing or to less DBISAM internals
knowledge.

What do you think about this? Will be my code fine this way?

Regards
Rolf [Team Elevate]
Image