Crear ODBC mediante código Visual Basic.

29/07/2003 - 16:49 por Alfredo | Informe spam
Hola,
como puedo crear un ODBC para AS-400 a través de código
Visual Basic?,
Bueno si alguien conoce, con otro proveedor que no sea AS-
400, igual puede servirme.

Gracias de antemano.
atte.
Alfredo
 

Leer las respuestas

#1 Pablo Crosio
29/07/2003 - 20:39 | Informe spam
Fijate si te sirve este fragmento de código...

Salu2!!

Pablo




Option Explicit
'For more information on keywords / attributes, look up
function name in SQL Server Books Online. Try MSDN too.
Declare Function SQLConfigDataSource Lib _
"ODBCCP32.DLL" _
(ByVal hwndParent As Long, _
ByVal fRequest As Long, _
ByVal lpszDriver As String, _
ByVal lpszAttributes As String) As Long

Sub Main()
AddODBCDataSource
End
End Sub

Public Sub AddODBCDataSource()

'You can modify to do any of the following.
Const ODBC_ADD_DSN = 1
Const ODBC_CONFIG_DSN = 2
Const ODBC_REMOVE_DSN = 3

Const vbAPInull As Long = 0&
Dim lngRet&, sDriver$, sAttributes$

'Any Driver Listed, under Drivers in ODBC Data Sources in
Control Panel, can be used here.
sDriver = "Microsoft Access Driver (*.mdb)"
sAttributes = "DSN=LocalDB" & Chr$(0) _
& "DBQ=C:\MyDocu~1\Test.mdb" & Chr$(0)
'Add all the Attributes / keywords you need here.

lngRet = SQLConfigDataSource(vbAPInull, _
ODBC_ADD_DSN, sDriver, sAttributes)

End Sub

Preguntas similares