15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Problem with reading OLE Object field data from Access throu

Teledata -- teledata@giasmd01.vsnl.net.in
Monday, July 08, 1996

Platform Windows '95, VC 4.1, MFC 4.

I am having Field of Type OLE Object type in access mdb, where I store
my data in the form of a BLOB. For reading and writing data into this
field, I am using ODBC classes provided by MFC version 4.

Datasource is created for Access driver supplied by Microsoft along with
Visual C++ ver 4. (ver 3.00.2127)
	
The recordset for the table containing Ole Object type field is created
using AppWizard. AppWizard creates a field of type CLongBinary. I have
however changed this to CByteArray. Further to change the default storage
size of 255 that RFX_Binary() function stores in database, I have increased
the size to INT_MAX, as advised in the help file.

"RFX_Binary(pFX, _T("[OLETABLE]"), m_OLEDATA, INT_MAX);"


Problem:
-------
	When I try to run the application using this recordset, at the point
when I call Open() on the recordset, the program stops with a message
"Bool Value cannot be more than value".

When I tried to find the source of this strange message and stepped through
the code, I noticed that during the binding of table fields, the driver was
reporting an abnormally high value of about 1 giga bytes as the precision of
the Ole Object field on calling SQLDescribeColumn(). The table at this time
was in fact empty.
The program tries to allocate memory of this size,and throws an exception.

At first this error could not be detected in VC++ ver 4.0 in debug mode. This
error first showed up in the release mode, and then debug mode itself after
I installed version 4.1.

	Please let me know if this behaviour was noticed before, and if there 
is a work around for this problem


Thanks

Prasad
Teledata Informatics,
Madras, India
Email: teledata@giasmd01.vsnl.net.in




Vincent Mascart -- 100425.1337@compuserve.com
Thursday, July 11, 1996

[Mini-digest: 3 responses]

>Platform Windows '95, VC 4.1, MFC 4.
>
>I am having Field of Type OLE Object type in access mdb, where I store
>my data in the form of a BLOB. For reading and writing data into this
>field, I am using ODBC classes provided by MFC version 4.
>
>Datasource is created for Access driver supplied by Microsoft along with
>Visual C++ ver 4. (ver 3.00.2127)
>	
>The recordset for the table containing Ole Object type field is created
>using AppWizard. AppWizard creates a field of type CLongBinary. I have
>however changed this to CByteArray. Further to change the default storage
>size of 255 that RFX_Binary() function stores in database, I have increased
>the size to INT_MAX, as advised in the help file.
>
>"RFX_Binary(pFX, _T("[OLETABLE]"), m_OLEDATA, INT_MAX);"
>
>
>Problem:
>-------
>	When I try to run the application using this recordset, at the point
>when I call Open() on the recordset, the program stops with a message
>"Bool Value cannot be more than value".
>
>When I tried to find the source of this strange message and stepped through
>the code, I noticed that during the binding of table fields, the driver was
>reporting an abnormally high value of about 1 giga bytes as the precision of
>the Ole Object field on calling SQLDescribeColumn(). The table at this time
>was in fact empty.
>The program tries to allocate memory of this size,and throws an exception.
>
>At first this error could not be detected in VC++ ver 4.0 in debug mode. This
>error first showed up in the release mode, and then debug mode itself after
>I installed version 4.1.
>
>	Please let me know if this behaviour was noticed before, and if there 
>is a work around for this problem

There is a VC++ 4.1 patch which correct this problem (and others)

You can get it going to 
http://www.microsoft.com/kb/developr/visual_c/q150937.htm


Vincent Mascart
100425.1337@compuserve.com

-----From: Zafir Anjum 

I had the same problem. Infact when I used VC++ 4.1 it started causing problem 
the memo field as well.

Anyway I tried the using the ODBC API directly but there seems to be a
problem with 
the ODBC driver for MS Access. When I used the MFC DAO classes I could read
the BLOB
from the database but could not write to it. Finally I used the DAO API
directly and 
that worked fine.

Here is a snippet of what I did


	CDaoDatabase mdb;
	CDaoRecordset rec(&mdb);

	

	CString dbname = theApp.m_db.GetDatabaseName() ;               //
theApp.m_db is an open CDatabase
        mdb.Open( dbname );
	CString str;

	str.Format( "SELECT * FROM [BinaryData] WHERE [id] = %ld", m_id );
	rec.Open(dbOpenDynaset, str);

	DAOFields *pflds;
	rec.m_pDAORecordset->get_Fields( &pflds );
	DAOField *pfld;
	pflds->get_Item( COleVariant((short)1), &pfld );
	pflds->Release();


        // just realized there is lot more code here but the main functions
used are
        // pfld->GetChunk(), pfld->AppendChunk() and some Variant functions
needed to
        // to pass the arguments to these functions


Hope this helps

Zafir




| Вернуться в корень Архива |