无法使用复杂的编程链创建 ADODB.Connection

发布于 2024-09-16 07:15:11 字数 685 浏览 2 评论 0原文

好吧,这是一个非常复杂的问题,我会尽力解释。

我们有一个 C++ 应用程序,它与 Sql Connection 进行通信,如下所示:

CoCreateInstance(_T("ADODB.Connection"))

这工作得很好。

我们最近将所有后端代码制作成 Com 对象。如果我编写一个 Vb 程序来加载 Com 对象并执行一些数据库操作,一切正常,CoCreateInstance(_T("ADODB.Connection"))
仍然有效。

我们使用fitnesse进行测试,所以我编写了一个固定装置:
1) 将一串 vb 代码输入到 html 页面中。
2)编译vb代码
3) 运行使用我们的 Com 对象的 vb 代码。
* Fitnesse 是一个 Java 应用程序,因此代码路径也通过 Java。

现在,当任何操作接触数据库时,Com 对象都会遇到异常。使用消息框,并删除代码我将问题缩小到这行代码:

CoCreateInstance(_T("ADODB.Connection"))

通常返回代码为 0,但是通过调用代码的此代码链,我得到返回代码:800401F3,它表示它无法找到要加载的对象。

我拉着头发试图弄清楚发生了什么事。任何一点见解都将不胜感激。

Ok so this is a really complicated problem, I will try my best to explain.

We have a c++ application which communicates with Sql Connection like so:

CoCreateInstance(_T("ADODB.Connection"))

This works fine.

We recently made all of our backend code into a Com Object. If I write a Vb program to load our Com Object and do some database operations everything works fine, CoCreateInstance(_T("ADODB.Connection"))
still works.

We use fitnesse for testing so I wrote a fixture that:
1) Takes a string of vb code input into an html page.
2) compiles the vb code
3) runs the vb code that uses our Com Object.
* fitnesse is a java application so the code path travels through Java as well.

Now when any operation touches the database the Com Object hits an exception. Uses message boxes, and removing code I narrowed the problem down to this line of code:

CoCreateInstance(_T("ADODB.Connection"))

normally the return code is 0, but with this chain of code calling code I get the return code: 800401F3 which says that it cannot find the object to load.

I am pulling my hair out trying to figure out whats going on. Any bit of insight would be greatly appreciated.

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

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

发布评论

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

评论(2

慈悲佛祖 2024-09-23 07:15:11

它告诉您在注册表中找不到 ProgId。这不是很健康,它是任何 Windows 安装上的一个相当标准的组件。验证这一点,启动 regedit.exe 并导航到 HKLM\Software\Classes\ADODB.Connection

如果缺少该连接,则需要在该计算机上安装 dbase 提供程序。从 Microsoft 下载 MDAC 2.8 安装程序并运行它。如果它没有丢失,那么您就会遇到一个更神秘的问题,可能与 64 位操作系统有关。然后查看 HKLM\Software\Wow6432Node。通过使用 SysInternals 的 ProcMon 工具来查看它在注册表中查看的内容,以获得更多诊断信息。

It is telling you that it cannot find the ProgId in the registry. That's not very healthy, it is a pretty standard component on any Windows install. Verify this, fire up regedit.exe and navigate to HKLM\Software\Classes\ADODB.Connection

If that is missing then you need to install the dbase providers on that machine. Download the MDAC 2.8 installer from Microsoft and run it. If it is not missing then you have a more mysterious problem, perhaps something to do with this being a 64-bit operating system. Look in HKLM\Software\Wow6432Node then. Get additional diagnostics by using the SysInternals' ProcMon tool to see what it is poking at in the registry.

久隐师 2024-09-23 07:15:11

作为替代方案,您不会说明您的 com“对象”是否是 .dll。如果是,请确保它是“自注册”,否则您需要在命令提示符下运行它。

regsvr32 myobject.dll

如果它是带有 COM 对象的 exe,请通过使用“/RegServer”命令行选项运行程序来注册对象,如下所示:

myobject.exe /RegServer

HTH

As an alternative, you don't say whether your com "object" is a .dll. If it is, then make sure it is either "self-registering" or you'll need to run this at the command prompt.

regsvr32 myobject.dll

If it's an exe with COM objects, register the objects by running the program with the "/RegServer" command line option like this:

myobject.exe /RegServer

HTH

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