开发者

Cannot create ADODB.Connection with complicated programming chain

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 mes开发者_StackOverflow社区sage 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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜