使用 ODBC 查询 Access 2007 多值字段

发布于 2024-07-29 19:06:32 字数 493 浏览 1 评论 0原文

我有一个 Access 2007 数据库,其字段之一使用“附件”数据类型(Access 2007 中的新增功能)。 该字段是一个神奇的“多值”字段,可以包含多个附件。

我希望能够使用单个 ODBC 查询轻松查看数据库中所有行的该字段的内容。 理想情况下,原始表的每一行应该恰好是一行,并且我希望所有附件作为单个数据库单元格返回。 在完美的世界中,可以使用单个 INSERT INTO 查询将该组附件重新插入到另一个表中。

我认为这可能是一个艰巨的任务,所以如果必须的话,我会满足于:

  • 一个 SQL 查询,告诉我给定附件字段中的附件数量

或最坏的情况:

  • 一个 SQL 查询,告诉我是否给定行中的附件是否为空。

我似乎在网上找不到任何关于多值字段的好文档。 也许它们太新了。

想法?

(PS 别费心告诉我多值字段是邪恶的。我已经知道了。我不是制作数据库的人。)

I have an Access 2007 database that uses the "Attachment" datatype (new in Access 2007) for one of its field. This field is a magical "multi-valued" field that can contain several attachments.

I would like to be able to easily see the contents of this field, for all the rows in the database, using a single ODBC query. Ideally, each row of the original table should be exactly one row, and I'd like all the attachments returned as a single database cell. In a perfect world, it would be possible to reinsert that set of attachments into another table using a single INSERT INTO query.

I think that might be a tall order, so if I have to, I'd settle for:

  • An SQL query that tells me the number of attachments in a given attachment field

or worst case:

  • An SQL query that tells me whether or not the attachments in a given row are empty or not.

I can't seem to find any good docs about multi-valued fields around on the net. Perhaps they're too new.

Thoughts?

(P.S. Don't bother telling me that multi-valued fields are evil. I already know. I'm not the one who made the database.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三生池水覆流年 2024-08-05 19:06:32

如果您可以使用 ADO,则无需在连接字符串中使用 OLEDB:Support Complex Data=True 连接到数据源并查询列:您应该获得一列类型adLongVarWChar(即MEMO),其中值是以分号字符分隔的文件名。 因此,获取文件列表仅涉及简单的解析。

也许可以使用 ADO 获取附件,但我还没有看到它完成。 使用 OLEDB:Support Complex Data=True 意味着您将获得一个 adIDispatch 类型的列,即一个对象。 我不知道那个对象是什么(我希望它是一个 ADODB.Recordset 但没有成功)。

If you can use ADO then connect to the data source without using OLEDB:Support Complex Data=True in the connection string and query the column: you should get a column of type adLongVarWChar (i.e. MEMO) where the value is the file names delimited by semicolon characters. Therefore, getting a list of files will merely involve a simple parse.

It may be possible to get the attachments using ADO but I've yet to see it done. Using OLEDB:Support Complex Data=True means you will get a column of type adIDispatch i.e. an object. What that object is, I do not know (I hoped it would be a an ADODB.Recordset but no go).

瞳孔里扚悲伤 2024-08-05 19:06:32

See http://www.access-freak.com/tutorials.html#Tutorial07 for some information although he doesn't have a good screenshot or SQL of the query. His website isn't the best formatted or readable either.

This assumes you're running the query from inside Access 2007. If you want to run it via ODBC see http://groups.google.ca/group/microsoft.public.data.odbc/browse_thread/thread/d0ee29cc5e54e0fb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文