问题描述
我正在研究一个MSProject插件,它将一些数据存储在MSAccess DB中。该插件工作正常,32位办公室工作正常。最近我们有一些客户安装64位办公室,因此要求我们提供64位版本
的加载项。我大部分完成了转换,但却无法访问数据库。我一直在寻找提示和想法的论坛和小组,但此时我完全被阻止了。下面的代码执行的操作很简单 - 我们
正在尝试使用新值更新文本字段,并且更新失败并出现数据库异常"无效的游标名称"。 CVersionTable继承自CRecordset,仅定义了所需的DDX功能。
我有一个64位Office 2010的完整安装,除此之外(以防万一)我安装了AccessDatabaseEngine_x64.exe和AccessRuntime_X64。可执行程序。但是似乎没有人能解决这个问题。
当我用原始SQL调用ExecuteSQL时,更新成功没有任何问题 - 这是方法结束时注释掉的行。
非常感谢任何帮助。
提前致谢,
Max
#if定义WIN64
#define MSACCESS_DRIVER _T("Microsoft Access驱动程序(* .mdb,* .accdb)\ 0"))
#else
#define MSACCESS_DRIVER _T(" Microsoft Access Driver(* .mdb)\0"))
#endif
void CTest :: TestCall()
{
TRY
{
CString strDsnAttributes = _T(" DSN = test1; DESCRIPTION = TOC支持来源; DBQ = project1.mdb; FIL = MS Access; DEFAULTDIR = c:\\test \\;" );
BOOL retVal = SQLConfigDataSource(NULL,ODBC_ADD_DSN,MSACCESS_DRIVER,strDsnAttributes);
CDatabase db;
retVal = db.Open(_T(" test1"));;
CVersionTable versionTable(& db );;
VERIFY(versionTable.Open());
if(!versionTable.GetRecordCount())
versionTable.AddNew();
else
versionTable.Edit();
versionTable.m_VERSION = _T(" 123");
versionTable.Update();
// db.ExecuteSQL(_T(" UPDATE VERSION SET VERSION ='123'"));
}
  ; CATCH(CDBException,dbe)
{
TRACE(_T(" CTest :: TestCall - %s"),dbe-> m_strError);
}
END_CATCH
}
Max
Hi,
I am working on a MSProject Add-in, that stores some of it's data in MSAccess DB. The add-in worked and still works just fine with 32bit office. Recently we had some customers installing 64-bit office and therefore requesting us to provide a 64-bit version of the add-in. I am mostly done with the conversion, but got stuck on accessing the DB. I've been poking around forums and groups looking for hints and ideas, but at this point I am completely blocked. The operation that code below performs is trivial - we are attempting to update a text field with a new value, and the update fails with DB exception "Invalid cursor name". CVersionTable inherits from CRecordset and merely defines the required DDX functionality.
I have a full installation of 64bit Office 2010, on top of that (just in case) I installed AccessDatabaseEngine_x64.exe and AccessRuntime_X64.exe. But neither one seemed to solve the problem.
When I call ExecuteSQL with raw SQL, the update succeeds without any problems - that is the commented out line at the end of the method.
Any help would be greatly appreciated.
Thanks in advance,
Max
#if defined WIN64
#define MSACCESS_DRIVER _T("Microsoft Access Driver (*.mdb, *.accdb)\0")
#else
#define MSACCESS_DRIVER _T("Microsoft Access Driver (*.mdb)\0")
#endif
void CTest::TestCall()
{
TRY
{
CString strDsnAttributes = _T("DSN=test1;DESCRIPTION=TOC support source;DBQ=project1.mdb;FIL=MS Access;DEFAULTDIR=c:\\test\\;");
BOOL retVal = SQLConfigDataSource(NULL,ODBC_ADD_DSN,MSACCESS_DRIVER,strDsnAttributes);
CDatabase db;
retVal = db.Open(_T("test1"));
CVersionTable versionTable(&db);
VERIFY(versionTable.Open());
if (!versionTable.GetRecordCount())
versionTable.AddNew();
else
versionTable.Edit();
versionTable.m_VERSION = _T("123");
versionTable.Update();
//db.ExecuteSQL(_T("UPDATE VERSION SET VERSION = '123'"));
}
CATCH(CDBException, dbe)
{
TRACE(_T("CTest::TestCall - %s"), dbe->m_strError);
}
END_CATCH
}
Max
这篇关于使用ODBC和64位MSAccess驱动程序在Windows 7 64位上进行表更新失败,错误“无效游标名称”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!