Connessione ADO ad Oracle in Excel, tramite vba


  • Installazione del driver oracle sulla macchina
  • Ado instalato sulla macchina

Per utilizzare ado in excel è sufficiente (versione 2003), dal vba editor di Excel, andare in Strumenti–>Riferimenti e scegliere Microsoft ActiveX data object.

ll codice:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim query As String
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "Driver={Oracle ODBC Driver};" & _
           "Dbq=" & database & ";" & _
           "Uid=" & uid & ";" & _
           "Pwd=" & password
query = "select * from persona"
rs.Open query, cn, adOpenStatic
While Not rs.EOF
Set rs = Nothing
Set cn = Nothing

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>