Article View: borland.public.cppbuilder.database.ado
Article #2519CreateBlobStream truncates BLOBs
From: Thomas Wagener
Date: Mon, 16 Jun 2003 09:53
Date: Mon, 16 Jun 2003 09:53
41 lines
2647 bytes
2647 bytes
Hi,
I have a problem with the ADO components in CBuilder 6 SP4 (German). Some of
my BLOBs get truncated when I try to read the content of the field with
either TADODataSet::CreateBlobStream or TField::Value. I am not really sure
if this is an ADO problem or a problem related to the Borland OleVariant
implementation. The fields of the ADO data set are initialized as
OleVariants. Unfortunately, the constructor of OleVariant uses
SysAllocString to intialize the OleVariant as BSTRs. In contrast to
SysAllocStringByteLen, SysAllocString expects a zero-terminated OLECHAR
string which is not really a good choice for a binary field.
The code I use is something like this:
TADOConnection* pConnection = new TADOConnection(0);
pConnection->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Scratch\\db\\franzgaul.xdb;Persist Security Info=False";
TADODataSet* pDataSet = new TADODataSet(0);
pDataSet->Connection = pConnection;
pDataSet->CommandType = cmdText;
pDataSet->CommandText = "Select * From tblDN Where DID=748";
pDataSet->Open();
while(!pDataSet->Eof){
TMemoryStream* pStream = new TMemoryStream();
TBlobField* pField = (TBlobField*)pDataSet->FieldByName("docmeta");
pStream = (TMemoryStream*)pDataSet->CreateBlobStream(pField,bmRead);
WideString ws = pField->Value;
int iFieldSize = pField->BlobSize;
int iMemorySize = pStream->Size;
// NOTE: Both iFieldSize and iMemorySize give the same wrong size.
delete pStream;
} // while
Field truncation does not occur with CBuilder 6 SP1.
Is this a known problem and is there a work-around to this? Or am I doing
something wrong?
Thanks,
Thomas
Technical Details
Message-ID:
<3eed935f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,bb7df0a8df52ad63,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-06-16 03:01:45 PST From: "Thomas Wagener" <Thomas.Wagener@web.de> Newsgroups: borland.public.cppbuilder.database.ado Subject: CreateBlobStream truncates BLOBs Date: Mon, 16 Jun 2003 11:53:25 +0200 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 217.234.5.152 Message-ID: <3eed935f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1055757151 217.234.5.152 (16 Jun 2003 02:52:31 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail