ODBC

M4
10 de Septiembre del 2004
Existe algun codigo para visual basic, utilizando la libreria shell de Wndows o alguna otra manera que permita agregar al sistema operativo una fuente de datos ODBC en la instalacion del programa sin necesidad de agregarla por el panel de control, o sea, no agregar una fuente OBDC manualmente sino via programa

de antemano gracias

rafa
10 de Septiembre del 2004
Hola:
Yo lo hago con este codigo:
Public Sub createDSN(sdsn As String, NombreDB As String)
Dim nRet As Long
Dim sDriver As String
'Dim sAttributes As String
Dim DirectorioDatos As String
On Error GoTo err_createDsn

DirectorioDatos = Mid(Trim(strDirection), 1, Len(Trim(strDirection)) - 1)
sDriver = "Microsoft Access Driver (*.mdb)"
sAttributes = sAttributes & "DESCRIPTION=" & sdsn & ";" & Chr$(0)
sAttributes = sAttributes & "DSN=" & sdsn & ";" & Chr$(0)
sAttributes = sAttributes & "DBQ=" & DirectorioDatos & Mid(Trim(NombreDB), 1, Len(Trim(NombreDB)) - 1) & ";" & Chr$(0)
sAttributes = sAttributes & "DataBase=" & NombreDB & ";" & Chr$(0)
sAttributes = sAttributes & "UID=" & usuario & ";" & Chr$(0)
sAttributes = sAttributes & "PWD=" & pasword & ";" & Chr$(0)

DBEngine.RegisterDatabase sdsn, "Microsoft Access Driver (*.mdb)", True, sAttributes
If CreaConexion = True Then
Exit Sub
End If
err_createDsn:
MsgBox Err.Number & " " & Err.Description, vbCritical, "Error de Conexion"

End Sub

Suerte

xtremekid
10 de Septiembre del 2004
Con respecto a lo del tipo de conexión me sale error 24 que se requiere un objeto, quisiera saber que objeto es el requerido y también si es necesario añadir algunas otras referencias?