#36 insufficient memory for this operation

open
nobody
None
5
2009-12-24
2009-12-24
Daniel
No

When connection to a SQL Server 2005 database and query for a string field with a value as long as the field itself I get the error message 'insufficient memory for this operation'.

I did the following corrections, now everything works fine:

DbxOpenOdbc.pas, function TSqlCursorOdbc.getColumnLength
Line 16633:
old:
fldZSTRING: // = 1; { Null terminated string }
begin
{ quantity of symbols without null terminator }
pLength := fColSize;
end;

new:
fldZSTRING: // = 1; { Null terminated string }
begin
{ quantity of symbols including null terminator }
pLength := fColSize + SizeOf(cNullAnsiChar);
end;

and maybe also on line 16740 (not tested):
old:
fldWIDESTRING, // = 26; { UCS2 null terminated string }
fldUNICODE: // = $1007; { Unicode }
begin
{ quantity of symbols without null terminator }
pLength := fColSize;
end;

new:
fldWIDESTRING, // = 26; { UCS2 null terminated string }
fldUNICODE: // = $1007; { Unicode }
begin
{ quantity of symbols including null terminator }
pLength := fColSize + SizeOf(cNullWideChar);
end;

Discussion