RE:Necesito crear DSN en tiempo de ejecucion
puedes usar un api SQLConfigDataSource, te paso el ejemplo
Sub RegistrarDSN()
' rutina que crea la DSN si no esta instalada en la maquina del
' usuario
' Ing. Isidro Almaguer de la Rosa, 14/sept/2001
Dim intRet As Integer
Dim strDriver As String
Dim strAttributes As String
'Set the driver to SQL Server because it is most common.
strDriver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete
'list of supported attributes.
strAttributes = "SERVER=tuservidor" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=desc de tu BD" & Chr$(0)
strAttributes = strAttributes & "DSN=tuDSN" & Chr$(0)
strAttributes = strAttributes & "DATABASE=TuBD" & Chr$(0)
'To show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, _
strDriver, strAttributes)
If intRet Then
MsgBox "DSN creada con exito..."
Else
MsgBox "No se pudo crear DSN..."
End If
End Sub
declaracion de la api en un modulo
' para creacion de DSN
'Constant Declaration
Const ODBC_ADD_DSN = 1 ' Add data source, user DSN
Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ' Remove data source
Const vbAPINull As Long = 0 '& amp ' NULL Pointer
Const ODBC_ADD_SYS_DSN = 4 ' Add data source, system DSN
Declare Function SQLConfigDataSource Li