Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BdpDataReader.GetBytes always returns 0

6 views
Skip to first unread message

David Clegg

unread,
Apr 3, 2007, 5:28:13 AM4/3/07
to
I am trying to read data from an Interbase blob field in small chunks,
but my attempts are falling flat because calls to
BdpDataReader.GetBytes always return 0 even though bytes are
successfully read from the database.

I can reproduce the problem with a more contrived example, and below is
the code I'm using for this :-

procedure TWinForm2.Button1_Click(sender: System.Object; e:
System.EventArgs);
var
lCon: BdpConnection;
lCmd: BdpCommand;
lReader: BdpDataReader;
lBuff: array of byte;
lRead: Int64;
begin
lCon := BdpConnection.Create;
lCon.ConnectionString := 'assembly=Borland.Data.Interbase,
Version=2.5' +
'.0.0, Culture=neutral,
PublicKeyToken=91d62ebb5b0d1b1b;vendorclient=gds32' +
'.dll;pooling=True;grow on
demand=True;database=localhost:D:\IBData\BLOBTEST' +
'.IB;username=SYSDBA;max pool
size=100;password=masterkey;provider=In' +
'terbase;min pool size=0';

lCmd := BdpCommand.Create('SELECT BLOB_FIELD FROM BLOB_TABLE WHERE ID
= 1', lCon);
lCon.Open;
try
lReader := lCmd.ExecuteReader(CommandBehavior.SequentialAccess);
try
SetLength(lBuff, 16384);
if lReader.Read then
begin
lRead := lReader.GetBytes(0, 0, lBuff, 0, Length(lBuff));
MessageBox.Show(lRead.ToString);
end;
finally
lReader.Close;
end;
finally
lCon.Close;
end;
end;


Is there anything obviously wrong with the above code, or are there any
known issues with BdpDataReader.GetBytes not correctly returning the
number of bytes read? I did a quick search in QC, but didn't find any
existing bug reports.

--
Cheers,
David Clegg
dcl...@gmail.com
http://cc.borland.com/Author.aspx?ID=72299

QualityCentral. The best way to bug Borland about bugs.
http://qc.borland.com

"Pffft. Who needs English? I'm never going to England." - Homer Simpson

David Wilcockson

unread,
Apr 10, 2007, 3:20:46 PM4/10/07
to

> if lReader.Read then
> begin
> lRead := lReader.GetBytes(0, 0, lBuff, 0, Length(lBuff));
> MessageBox.Show(lRead.ToString);
> end;
> finally
> lReader.Close;
> end;


Try calling it separately with a nil to get the size first. This is the code
I use (and I believe it worked when I used to use BDP):

BlobSize := SQLReader.GetChars(0, 0, nil, 0, 0);
SetLength(BlobArray, BlobSize);
if BlobSize <> 0 then SQLReader.GetChars(0, 0, BlobArray, 0,
BlobSize);


David Clegg

unread,
Apr 10, 2007, 4:40:09 PM4/10/07
to
David Wilcockson wrote:

> Try calling it separately with a nil to get the size first. This is
> the code I use (and I believe it worked when I used to use BDP):

This is what the original code is currently doing, so I am dubious as
to whether this will solve the problem. However, I'll add it to my test
app so I can know for sure that nothing else is causing this behaviour.

--
Cheers,
David Clegg
dcl...@gmail.com

http://cc.codegear.com/Author/72299

QualityCentral. The best way to bug CodeGear about bugs.
http://qc.codegear.com

0 new messages