connection from VS 2008 to access 2007

ripp3r

Registered User.
Local time
Tomorrow, 00:00
Joined
Apr 9, 2009
Messages
11
Hi guys,

I'm experience a strange problem.

I wrote an application with my computer running Visual Basic Express 2008.

I created a module where I put my function, for example to OPEN my db I use this:

Code:
Public conn As ADODB.Connection


    Public Function ApriConn()
        conn = New ADODB.Connection
        With conn
            .ConnectionString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documenti\MaterialeStampa.accdb"
            .Open()
        End With
    End Function

To close:

Code:
Public Function ChiudiConn()
        conn.Close()
        Conn = Nothing
    End Function

Once the connection is open I use this to work with my tables:

Code:
Public Function Ftcl(ByVal stato As Boolean)
        If stato = True Then
            tcl = New ADODB.Recordset
            With tcl
                .ActiveConnection = conn
                .CursorType = ADODB.CursorTypeEnum.adOpenStatic
                .CursorLocation = ADODB.CursorLocationEnum.adUseClient
                .LockType = ADODB.LockTypeEnum.adLockOptimistic
                .Open("Clienti")
            End With
        Else
            tcl.Close()
            tcl = Nothing
        End If
    End Function

Everything here's working fine, but now I'm at work and as said I'm using visual studio 2008.

If I put the SAME code in my project and I run the ApriConn function I get this error:

Code:
Impossibile eseguire il cast di oggetti COM di tipo 'ADODB.ConnectionClass' in tipi di interfaccia 'ADODB._Connection'. L'operazione non è stata completata perché la chiamata QueryInterface sul componente COM per l'interfaccia con IID '{00000550-0000-0010-8000-00AA006D2EA4}' non è riuscita a causa del seguente errore: Interfaccia non supportata. (Eccezione da HRESULT: 0x80004002 (E_NOINTERFACE)).


And the line highlighted is:

Code:
.ConnectionString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MaterialeStampa.accdb"


At the beginning of my project I added these references:


Microsoft ActiveX Data Objects 2.8 Library
and
Microsoft DAO 3.6 Object Library

Also at the top of the code I have:

Code:
Imports System.Data
Imports System.Data.OleDb
Imports ADODB


But if I use this code everything is fine:

Code:
Public conn As New OleDb.OleDbConnection

Public Function connessione()
        conn.ConnectionString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MaterialeStampa.accdb"
End Function


Now the questions are two:

1) why ADODB is not working?
2) how can I manage tables (read, write, modify) with OLEDB?

Thanks all!
 

Users who are viewing this thread

Back
Top Bottom