tZConnection connected to mssql using ntwdblib
tZQuery using tZConnection with following sql
SELECT top 1 name, convert(varchar(100), '') as name1, name as name2 from sysobjects
when open query return for name1 column the value of name column
i traced the problem into
ZDbcCachedResultSet.pas in fetch
Code: Select all
//stString: RowAccessor.SetPChar(I, ResultSet.GetPChar(I));
// gto: do we need PChar here? (Unicode problems)
stString: RowAccessor.SetString(I, ResultSet.GetString(I));
ZDbcDbLibResultSet.pas
function TZDBLibResultSet.GetString(ColumnIndex: Integer): AnsiString;
DL for name1 returns 1
Data return ' ' one space character
it is decreased and the Result is not set anymore and in Delphi 2007 remains the previous Result ( the value of name column in this example)
i made the following code change and work so far :
Code: Select all
function TZDBLibResultSet.GetString(ColumnIndex: Integer): AnsiString;
var
DL: Integer;
Data: Pointer;
DT: Integer;
begin
CheckClosed;
CheckColumnIndex(ColumnIndex);
DL := FPlainDriver.dbDatLen(FHandle, ColumnIndex);
Data := FPlainDriver.dbdata(FHandle, ColumnIndex);
DT := DBLibColTypeCache[ColumnIndex];
LastWasNull := Data = nil;
Result := '';
if Assigned(Data) then
begin
case DT of
SQLCHAR, SQLTEXT:
begin
while (DL > 0) and (PAnsiChar(Integer(Data) + DL - 1)^ = ' ') do
Dec(DL);
if DL > 0 then
begin
SetLength(Result, DL);
Move(Data^, PAnsiChar(Result)^, DL);
end;
end;
SQLIMAGE:
begin
SetLength(Result, DL);
Move(Data^, PAnsiChar(Result)^, DL);
end;
else
begin
SetLength(Result, 4001);
DL := FPlainDriver.dbconvert(FHandle, DT, Data, DL, SQLCHAR, Pointer(PAnsiChar(Result)), Length(Result));
while (DL > 0) and (Result[DL] = ' ') do
Dec(DL);
SetLength(Result, DL);
end;
end;
end;
//else
FDBLibConnection.CheckDBLibError(lcOther, 'GETSTRING');
end;
It this ok ? or it is other way around ?