ronando
Messages postés141Date d'inscriptionlundi 24 décembre 2001StatutMembreDernière intervention 5 juillet 2007
-
26 mars 2002 à 16:23
Apodemus
Messages postés24Date d'inscriptionvendredi 25 janvier 2002StatutMembreDernière intervention17 avril 2002
-
4 avril 2002 à 13:09
Apodemus
Messages postés24Date d'inscriptionvendredi 25 janvier 2002StatutMembreDernière intervention17 avril 2002 4 avril 2002 à 13:09
un truc brut de fonderie, mais qui marche et que j'utilise
'DECLARATIONS
Public Declare Function SQLAllocEnv% Lib "odbc32.dll" (env&)
Public Declare Function SQLDataSources Lib "odbc32.dll" _
(ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, _
pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, _
pcbDescription%) As Integer
Public Const SQL_SUCCESS As Long = 0
Public Const SQL_FETCH_NEXT As Long = 1
public gaDSNListe() As String
'EXEMPLE DE PROCEDURE
Function GetAllDSNs() As Integer 'retourne le nombre de DSN
Dim sDSNItem As String * 1024, sDRVItem As String * 1024
Dim sDSN As String, sDRV As String, nbdns As Integer
Dim iDSNLen As Integer, iDRVLen As Integer
Dim lHenv As Long, resu As Integer
On Error Resume Next
If SQLAllocEnv(lHenv) <> -1 Then
Do
sDSNItem = Space(1024)
sDRVItem = Space(1024)
resu = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
If resu = SQL_SUCCESS Then
ReDim Preserve gaDSNListe(1, nbdns)
gaDSNListe(0, nbdns) = left(sDSNItem, iDSNLen)
gaDSNListe(1, nbdns) = left(sDRVItem, iDRVLen)
nbdns = nbdns + 1
End If
Loop While resu = SQL_SUCCESS
End If
GetAllDSNs = nbdns
End Function
on a dans gaDSNListe(i) le nom du DSN et le type de driver ODBC