querytables.add ADO oracle
Bonjour,
J'ai créé cette fonction qui me permet de connecter à une base oracle
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Private Function GetConnectionValues() As Boolean
ODBC_STRING = InputBox("ODBC Connection Name to the database ?")
ORACLE_USER = ORACLE_USER_VALUE
ORACLE_PASS = ORACLE_PASS_VALUE
CONNECTION_STRING = "Driver={Microsoft ODBC for Oracle};" & "Server=" & ODBC_STRING & ";" & "Uid=" & ORACLE_USER & ";" & "Pwd=" & ORACLE_PASS & ";"
If ODBC_STRING = "" Then
GetConnectionValues = False
Else
GetConnectionValues = True
End If
WK = ActiveWorkbook.name
End Function |
j'appelle cette fonction mais je ne sais pas comment utiliser querytables.add afin d'ajouter les données de ma requête dans une feuille excel.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub Extraction()
' Extraction Macro
' Eric Terrien
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim req As String
req = "SELECT ...
If GetConnectionValues = False Then
Call ReactivateExcel
Call MsgBox(STOPPED_BY_USER_POPUP_TEXT)
Exit Sub
End If
'Connect Database
cnn.Open CONNECTION_STRING
rst.Open req, cnn, adOpenForwardOnly, adLockReadOnly
.
.
. |
Merci de m'aider afin d’intégrer querytables.add dans mon code.