如何用OLEDB组件接口访问包含有多个BLOB字段的表?

Brierbird 2004-06-18 03:57:31
单一BLOB字段时IRowset->GetData(...)函数正常;但是当有多个BLOB字段时,就出错,怎么办?谢谢先!
...全文
117 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Brierbird 2004-09-13
  • 打赏
  • 举报
回复
sigh...没有得到正解,CSDN又要强制结贴了:(
Brierbird 2004-08-08
  • 打赏
  • 举报
回复
我倒是没试过能过多个访问器来访问,如果用多个的话,那我觉得应该可以实现,即一个访问器只读出一个BLOB。但问题在于,由于我做的是一个通用接口,因此,如果这么做的话,在内部,我需要根据用话的一次取值要求,判断出其中要求的字段是否包括多个BLOB,如果是,那就需要构建多个,麻烦,倒也不是不能实现。
如果的确只有此华山一条路,那倒也可以做罢,如果另有蹊径,那自然是首选,放弃已有的功能不用,而自己去实现,不只是一种浪费,还可能导致一些不应有的BUG的出现。

嗯,再问问,还有哪位大牛对此有见解哪,谢谢!
laker_tmj 2004-08-07
  • 打赏
  • 举报
回复
你有沒有試過用多個訪問器(IAccessor)來訪問不同的 blob ?
laker_tmj 2004-08-07
  • 打赏
  • 举报
回复
好像不行!(我英文不好,有以下文檔)
BLOBs and OLE Objects
SQLOLEDB exposes the ISequentialStream interface to support consumer access to Microsoft® SQL Server™ 2000 ntext, text, and image data types as binary large objects (BLOBs). The Read method on ISequentialStream allows the consumer to retrieve large amounts of data in manageable chunks.

SQLOLEDB can use a consumer-implemented IStorage interface when the consumer provides the interface pointer in an accessor bound for data modification.

SQLOLEDB Storage Object Limitations
SQLOLEDB can support only a single open storage object. Attempts to open more than one storage object (attempts to get a reference on more than one ISequentialStream interface pointer) return DBSTATUS_E_CANTCREATE.


In SQLOLEDB, the default value of the DBPROP_BLOCKINGSTORAGEOBJECTS read-only property is VARIANT_TRUE. This indicates that if a storage object is active, some methods (other than those on the storage objects) will fail with E_UNEXPECTED.


The length of data presented by a consumer-implemented storage object must be made known to SQLOLEDB when the row accessor that references the storage object is created. The consumer must bind a length indicator in the DBBINDING structure used for accessor creation.


SQLOLEDB supports the ISequentialStream::Write method for zero-length strings and NULL values only. Attempts to write more than zero bytes through ISequentialStream::Write fail.


If a row contains more than a single large data value, and DBPROP_ACCESSORDER is not DBPROPVAL_AO_RANDOM, the consumer must either use a SQLOLEDB cursor-supported rowset to retrieve row data or process all large data values prior to retrieving other row values. If DBPROP_ACCESSORDER is DBPROPVAL_AO_RANDOM, SQLOLEDB caches all the BLOB data so it can be accessed in any order.

Getting Large Data
In general, consumers should isolate code that creates a SQLOLEDB storage object from other code that handles data not referenced through an ISequentialStream interface pointer.

If the DBPROP_ACCESSORDER property (in the rowset property group) is set to either of the values DBPROPVAL_AO_SEQUENTIAL or DBPROPVAL_AO_SEQUENTIALSTORAGEOBJECTS, the consumer should fetch only a single row of data in a call to the GetNextRows method because BLOB data is not buffered. If the value of DBPROP_ACCESSORDER is set to DBPROPVAL_AO_RANDOM, the consumer can fetch multiple rows of data in GetNextRows.

SQLOLEDB does not retrieve large data from Microsoft® SQL Server™ until requested to do so by the consumer. The consumer should bind all short data in one accessor, and then use one or more temporary accessors to retrieve large data values as required.
Brierbird 2004-08-06
  • 打赏
  • 举报
回复
还是没有结解决。使用MSDN中的MSDN中的例子,RowsetViewer,结果发现,好像也是不支持。但问题是ADO应该是支持的吧?那也就说明有一种机制能实现,只是我没能想着,大家帮着出点主意吧,谢谢!
laker_tmj 2004-07-28
  • 打赏
  • 举报
回复
還沒解決?
Brierbird 2004-07-28
  • 打赏
  • 举报
回复
再问
MajorVon 2004-07-01
  • 打赏
  • 举报
回复
可能我是一个老程序员的缘故吧.

对于BLOB字段我个人认为还是ODBC好使.可能我自己ODBC用得多的原因.

现在用ADO,发现这东西不太好使..

过于抽象后虽然简单了.但不好控制...
CsdnRob 2004-07-01
  • 打赏
  • 举报
回复
可能我是一个老程序员的缘故吧. 对于BLOB字段我个人认为还是ODBC好使.可能我自己ODBC用得多的原因. 现在用ADO,发现这东西不太好使.. 过于抽象后虽然简单了.但不好控制...
CsdnRob 2004-07-01
  • 打赏
  • 举报
回复
可能我是一个老程序员的缘故吧. 对于BLOB字段我个人认为还是ODBC好使.可能我自己ODBC用得多的原因. 现在用ADO,发现这东西不太好使.. 过于抽象后虽然简单了.但不好控制...
Brierbird 2004-06-30
  • 打赏
  • 举报
回复
to sinfee: 单一的BLOB字段好处理,问题在于多个。而且多个的时候,如果将其全部当作BSTR/WSTR/STR/BYTE来处理,也问题不大,但如果全当作ISequentialStream,则是不行的,MSDN中也给出了相应的说明。这一点上,如果用MSDN中提供的RowsetViewer就可以知道了。
但现在问题是,ADO是如何将二者结合的?也就是说从ADO访问的话,用户是不需要知道表中是含有多少个BLOB,一切都是可以的。
PiggyXP 2004-06-21
  • 打赏
  • 举报
回复
我也只是做过一个blob字段的

难道多个blob字段就不一样了吗?

up一下,愿闻高手指点
sinfee 2004-06-21
  • 打赏
  • 举报
回复
请问一个BLOB的如何实现读写?
http://community.csdn.net/Expert/topic/3108/3108700.xml?temp=.4618341

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧