COM Error in ADODB connection

0

In my console application i have this simple database connectivity code. But it shows COM exception error in ADODB.Connection line.

  Module Module1    
        Sub Main()
            Dim cn As New ADODB.Connection() //error 
            cn.ConnectionString = "provider=sqloledb;server=localhost;database=northwind;uid=<username>"
            cn.Open()
        End Sub    
    End Module

I added Microsoft Activex Data objects 2.8 library in reference,but error appeared. I changes the library to Microsoft Activex Data objects 6.0 library, but still it shows the error. When i run the applicaiton first it shows one error-

The procedure entry point _LoadVersionedResourceEx@16 could not be located in MSDART.dll.

and then

COM Exception unhandled:
Retrieving the COM class factory for component with CLSID {00000514-0000-0010-8000-00AA006D2EA4} failed due to the following error: 8007007f The specified procedure could not be found. (Exception from HRESULT: 0x8007007F).

Im using windows 7, Visual studio 2010, vb.net

vb.net
com
oledb
asked on Stack Overflow May 14, 2015 by Anu • edited May 14, 2015 by ɐsɹǝʌ ǝɔıʌ

1 Answer

0

Probably you have an obsolete Msdart.dll file in your %windir%\System32

Replace it with the correct Msdart.dll (v2.71.9031.4) file that is located in your %windir%\System32\Dllcache folder.

Another work around is to include Microsoft Data Access Components library in Project > Add reference > COM tab

answered on Stack Overflow May 14, 2015 by ɐsɹǝʌ ǝɔıʌ

User contributions licensed under CC BY-SA 3.0