CRecordset :: snapshot在VS2012不工作了 - 什么是替代方法? [英] CRecordset::snapshot doesn't work in VS2012 anymore - what's the alternative?

查看:210
本文介绍了CRecordset :: snapshot在VS2012不工作了 - 什么是替代方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,在VS2012中,SQL_CUR_USE_ODBC已弃用。 [更新:看起来游标库已经从VS2012完全删除]。



MFC的CDatabase不再使用它了(而VS2010和更早版本不幸的是,SQL_CUR_USE_DRIVER不能与Jet ODBC驱动程序正常工作(我们正在与Access数据库交互)。驱动程序最初声称支持位置操作(但不是位置更新),但是当尝试实际查询数据库时,所有并发模型失败,直到MFC库下降到与数据库的只读交互(这不会




  • 这是MS的最新尝试强制开发人员远离基于Jet的数据源并迁移到SQL Express(或类似)?

  • 我们应该使用其他模式通过VS 2012版本的MFC / ODBC与我们的Access数据库交互吗?(1)



另请参阅:
http://social.msdn.microsoft.com/Forums/kk/vcmfcatl/thread/acd84294-c2b5-4016-b4d9-8953f337f30c






更新:查看各种选项,似乎光标库已从VS2012的ODBC库中删除。结合Jet不能正确支持位置更新(2)的事实,它使快照模式不可用。它似乎支持dynaset,只要基础表有一个主键。未锁定的表与dynaset模式(3)不兼容。所以 - 我可以坚持使用VS 2010,或者我可以更改我的表包括自动编号或类似的东西,以确保pkey可用,所以我可以使用动态集模式的记录集。






(1)eg我们应该使用不同的开放类型为CRecordset?我们目前使用CRecordset :: snapshot。但我从来没有真正理解各种模式快照,动态,动态。一个快速的尝试每一个没有得到一个工作的可更新接口我们的访问数据库...

(2)它声称,当最初查询,但然后返回所有并发模式的错误,它以前声称支持

(3)动态也出来,因为Jet不支持它(从我从我的测试可以告诉)。



如果有其他人遇到这个问题,这里是什么似乎是答案:

一个Access数据库,使用CDatabase mydb连接; mydb.OpenEx(..,0),因此您要求系统不要加载游标库。



然后对于记录集,使用dynaset CMyRecordset myrs; myrs.Open(CRecordset :: dynaset,...)。



最后,你必须确保你的表有一个主键为了使用dynasets 。


Apparently, in VS2012, SQL_CUR_USE_ODBC is deprecated. [Update: it appears that the cursors library has been removed from VS2012 entirely].

MFC's CDatabase doesn't use it anymore (whereas it was the default for VS2010 and earlier versions of MFC), but instead uses SQL_CUR_USE_DRIVER.

Unfortunately, SQL_CUR_USE_DRIVER doesn't work properly with the Jet ODBC driver (we're interacting with an Access database). The driver initially claims to support positional operations (but not positional updates), but when an attempt is made to actually query the database, all concurrency models fail until the MFC library drops down to read-only interaction with the database (which is not going to fly for us).

Questions

  • Is this MS's latest attempt to force devs to move away from Jet based datasources and migrate to SQL Express (or the like)?
  • Is there another modality that we should be using to interact with our Access databases through VS 2012 versions of MFC/ODBC?(1)

See also: http://social.msdn.microsoft.com/Forums/kk/vcmfcatl/thread/acd84294-c2b5-4016-b4d9-8953f337f30c


Update: Looking at the various options, it seems that the cursor library has been removed from VS2012's ODBC library. Combined with the fact that Jet doesn't correctly support positional updates(2), it makes "snapshot" mode unusable. It does appear to support "dynaset" as long as the underlying tables have a primary key. Unkeyed tables are incompatible with "dynaset" mode(3). So - I can stick with VS 2010, or I can change my tables to include an autonumber or something similar in order to ensure a pkey is available so I can use dynaset mode for the recordsets.


(1) e.g. should we be using a different open type for CRecordset? We currently use CRecordset::snapshot. But I've never really understood the various modes snapshot, dynamic, dynaset. A quick set of "try each" has failed to get a working updatable interface to our access database...
(2) it claims to when queried initially, but then returns errors for all concurrency modes that it previously claimed to support
(3) "dynamic" is also out, since Jet doesn't support it at all (from what I can tell from my tests).

解决方案

If anyone else runs into this issue, here's what seems to be the answer:

For ODBC to an Access database, connect using CDatabase mydb; mydb.OpenEx(.., 0), so that you ask the system not to load the cursor library.

Then for the recordsets, use dynaset CMyRecordset myrs; myrs.Open(CRecordset::dynaset, ...).

Finally, you must make sure that your tables have a primary key in order to use dynasets (keysets).

这篇关于CRecordset :: snapshot在VS2012不工作了 - 什么是替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆