ODBC 是来自 MARS,而 ADO/OLEDB 是来自 VENUS?

发布于 2024-08-22 04:43:49 字数 488 浏览 5 评论 0原文

简短的问题: 我发现我需要通过 ODBC 使用 MARS,但不需要通过 ADO/OLEDB,这是正确的吗?

更长的解释:

我刚刚发现我的 ODBC 代码(使用“Driver={SQL Native Client}”,MFC CDatabase 代码)需要有 MARS(“MARS_Connection=yes;”),因为尽管我在打开 RecordSet 时不会发出多个 SELECT ,我确实获取了一批行,然后需要打开另一个 RecordSet 来发出新的 SELECT,然后返回到下一批的第一个 RecordSet。如果没有 MARS,我会收到 ODBC 错误“连接正忙于处理另一个命令的结果”。一切都很公平。

但是,我的代码与 ADO/OLEDB(“Provider=SQLNCLI”,#import msado15.dll)而不是 ODBC 的工作方式相同。在同样的情况下,我不必必须指定“MarsConn=yes”。

我很困惑/惊讶。这是正确的/预期的,还是我错过了什么?

Short question:
I am finding I need to use MARS over ODBC but not over ADO/OLEDB, is that correct?

Longer explanation:

I just discovered my ODBC code (using "Driver={SQL Native Client}", MFC CDatabase code) needs to have MARS ("MARS_Connection=yes;") because, although I do not issue multiple SELECTs when opening a RecordSet, I do fetch a batch of rows, then need to open another RecordSet to issue a new SELECT, and then return to the first RecordSet for the next batch. Without the MARS I get ODBC error "Connection is busy with results for another command". All fair enough.

However, my code works identically with ADO/OLEDB ("Provider=SQLNCLI", #import msado15.dll) instead of ODBC. In the same situation, I have not had to specify "MarsConn=yes".

I am confused/surprised. Is this correct/expected, or am I missing something?

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

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

发布评论

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

评论(1

贱贱哒 2024-08-29 04:43:49

如果有人感兴趣,我会发现问题/差异是什么。由于 ADO 案例中的一个微妙问题,我不得不重新审视代码,结果证明这是相关的。

如果您需要多个并发记录集,使用 ODBC 很容易,因为如果您不使用 MARS,它只会出现错误,如上所述。

然而,对于 ADO/OLEDB,情况就更微妙了。当我不使用 MARS 时,多个记录集似乎工作正常。但是,在幕后,ADO 会自动为每个会话打开另一个新会话,但您对此一无所知,也无法辨别。事实证明这真的很慢,因为每个会话都需要完整的审核登录和登录。关闭,我一直在创造、关闭和重新创造。

因此,我为 ADO 输入“MARS Connection=True”,并且,lo &看吧,它现在的行为就像 ODBC 一样,重新使用现有连接而不是创建新连接。

所以道德是:你必须有用于ODBC的MARS,而ADO/OLEDB将通过做自己的事情来允许没有MARS的多个并发记录集,但它可能(很好)不是你想要的/是的最好的。

If anyone is interested, I found out what the problem/difference is. I had to revisit code because of a subtle problem in the ADO case, which turned out to be related.

If you need multiple concurrent RecordSets, it's easy with ODBC, because if you don't use MARS it just errors, as above.

With ADO/OLEDB, however, it's more subtle. When I do not use MARS, multiple RecordSets seem to just work OK. But, under the covers, what happens is that ADO auto-opens another new session for each one, but you don't know about it and cannot tell. And that turns out to be real slow, because each session requires a complete audit logon & off, and I'm creating, closing, and re-creating all the time.

So I put in "MARS Connection=True" for ADO and, lo & behold, it now behaves just like ODBC, re-using the existing connection instead of creating new ones.

So the moral is: you have to have MARS for ODBC, while ADO/OLEDB will allow multiple concurrent RecordSets without MARS by doing its own thing, but it may (well) not be what you want/is best.

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