Visual Basic - Conexion ODBC mediante DAO

Life is soft - evento anual de software empresarial
 
Vista:

Conexion ODBC mediante DAO

Publicado por yako (12 intervenciones) el 12/10/2004 20:23:00
Hola,

estoy intentando abrir una base de datos mediante ODBC (con DAO)pero no lo consigo. Tengo el siguiente código:
.... (las variables están declaradas)
Set objWSpace = DBEngine.Workspaces(0)
Set objBDatos = objWSpace.OpenDatabase("prueba2", _
dbDriverNoPrompt, True, _
"ODBC;DATABASE=prueba;DSN=prueba2")
y siempre me da el siguiente error: Error 3423...No puede utilizar ODBC para importar o vincular a su base de datos una tabla externa de Microdoft Jet o de una base de datos ISAM.

Estoy utilizando Access 2002, Windows XP y VB 6.0.
¿Alguien me puede ayudar? Gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Conexion ODBC mediante DAO

Publicado por miguel (1042 intervenciones) el 13/10/2004 00:34:17
Prueba con este codigo:
Sub NewDatabaseCode()

Dim wrkMain As Workspace
Dim conPubs As Connection
Dim dbsPubs As Database
Dim prpLoop As Property

' Create ODBCDirect Workspace object instead of Microsoft
' Jet Workspace object.
Set wrkMain = CreateWorkspace("", "admin", "", dbUseODBC)

' Open Connection object based on information in
' the connect string.
Set conPubs = wrkMain.OpenConnection("DsnAcess", _
dbDriverNoPrompt, False, _
"ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=DsnAcess")
' Assign the Database property to the same object
' variable as in the old code.
Set dbsPubs = conPubs.Database

' Enumerate the Properties collection of the Database
' object. From this point on, the code is the same as the
' old example.
With dbsPubs
Debug.Print "Database properties for " & _
.Name & ":"

On Error Resume Next
For Each prpLoop In .Properties
If prpLoop.Name = "Connection" Then
' Property actually returns a Connection object.
Debug.Print " Connection[.Name] = " & _
.Connection.Name
Else
Debug.Print " " & prpLoop.Name & " = " & _
prpLoop
End If
Next prpLoop
On Error GoTo 0
End With
dbsPubs.Close
wrkMain.Close
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar