Thread View: borland.public.delphi.database.bdp
3 messages
3 total messages
Started by David Clegg
Tue, 03 Apr 2007 09:28
BdpDataReader.GetBytes always returns 0
Author: David Clegg
Date: Tue, 03 Apr 2007 09:28
Date: Tue, 03 Apr 2007 09:28
66 lines
2909 bytes
2909 bytes
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
dclegg@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
Re: BdpDataReader.GetBytes always returns 0
Author: David Wilcockson
Date: Tue, 10 Apr 2007 19:20
Date: Tue, 10 Apr 2007 19:20
18 lines
1513 bytes
1513 bytes
> 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);
Re: BdpDataReader.GetBytes always returns 0
Author: David Clegg
Date: Tue, 10 Apr 2007 20:40
Date: Tue, 10 Apr 2007 20:40
17 lines
1395 bytes
1395 bytes
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 dclegg@gmail.com http://cc.codegear.com/Author/72299 QualityCentral. The best way to bug CodeGear about bugs. http://qc.codegear.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads