DAODBEngine

G'day

After a VB6 to VB.NET 2.0 upgrade I am left with an IBM DB connection problem. The original version works. The upgrade doesn't. They are both running on the same PC and are configured the same.

Original Code:

Public dbIBMHost As Database
Set dbIBMHost = Workspaces(0).OpenDatabase("", False, False, _
"ODBC;DSN=ValidDSN;UID=ValidUserID;PWD=ValidPassword;")


New Code

Public dbIBMHost As dao.Database
dbIBMHost = DAODBEngine_definst.Workspaces(0).OpenDatabase("", False, False, _
"ODBC;DSN=ValidDSN;UID=ValidUserID;PWD=ValidPassword;")


and the upgrade kindly supplied the following Module to define DAODBEngine_definst

Module UpgradeSupport
Friend DAODBEngine_definst As New dao.DBEngine
End Module

The Project References list includes 'dao' and there is nothing obviously wrong, like null objects, but the following error occurs:

{Microsoft.VisualBasic.ErrObject}
Description: "ODBC--connection to 'ValidDSN' failed."
Erl: 34
HelpContext: 5003151
HelpFile: "jeterr40.chm"
LastDllError: 0
Number: 3151
Source: "DAO.Workspace"


I'm at a loss. Hope someone can help.
Cheers

Maz




Answer this question

DAODBEngine

  • DevDiver


    The reason that I suggested the PIA is because there seems to be an issue with the generic DAO interop library that is causing your issue. I don't know for certain whether the Office PIA for DAO would resolve the issue, but it might be worth a try.

  • Henrik Dahl


    Have you tried the ODBCDirect Workspace in DAO

  • Emphyrio

    Hi Paul

    I am using the 'Microsoft DAO 3.6 Object Library' ActiveX control. The reference was added by the Visual Studio automatic upgrade and is exactly the same one used by the VB6 version. I am curious why you asked this question, as I assume the Office PIA would only be concerned with connecting to Access DBs, which I have no problem with. It is only the ODBC connection that is broken (probably incidental, but the DB in question is an IBM iSeries).

    I'm still no closer to a solution so any help would be greatly appreciated.

    Many Thanks



  • dmbrubac

    Hi John

    I haven't been able to solve this problem. I can confirm that the DAO engine is fine from it's use in opening Access databases. Considering that, and that it all works in VB6, my best guess is that some 'ODBC enabling' component/reference needs to be added to the .NET project. Or perhaps the second (options) parameter is required now. Any ideas



  • TIG_TIG

    Hi Maz,

    Looking at the code snippet you've sent I can not see any reason why this would fail. The DAO Engine should be instantiated via COM Interop and work just as your VB6 project did. The UpgradeSupport module is just creating the DBEngine for you since in VB6 it would have been created when you first invoked a property or method.

    Were you able to narrow this down at all



  • johnny83


    Are you using the Office PIA or just the generic DAO interop assembly that is generated when you add the reference to your project

  • nairB

    Thanks for the suggestion Paul.

    Unfortunately, my project also accesses an Access database. It seems that prevents me using ODBCDirect.

    Ideally I would rewrite the database parts with ADO.NET but the powers that be have not included this option.

    This problem is still unresolved if anyone has any more suggestions....



  • qrli

    Hi Paul

    Now I understand your reasoning. I didn't realise the PIAs contained a dao.dll

    I'm now using this new dll (version 10.0.4504.0) but get exactly the same result.

    Any more ideas



  • Laurent Kempé


    You can most certainly create multiple Workspaces and use both ODBCDirect and the native Workspace objects together.

  • DAODBEngine