Hi All,
I have successfully connected excel to SQL developer using the below VBA code. I have oracle client and oracle dc drive in my machine.
Dim con As ADODB.connection
Dim rs As ADODB.Recordset
Dim Cmd As New ADODB.Command
Dim query As String
Dim strsql As String
Dim a As Integer
'Dim db As Dao.Database
Set con = New ADODB.connection
Set rs = New ADODB.Recordset
Application.ScreenUpdating = True
Cmd.CommandType = adCmdText
'--- Replace below highlighted names with the corresponding values
strCon = "Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=hostname)(PORT=portnum))" & _
"(CONNECT_DATA=(SERVICE_NAME=ser_name))); uid=username; pwd=password;"
'--- Open the above connection string.
con.Open (strCon)
***sql query*****
rs.Open strsql, con
Sheets(1).Range("A2").CopyFromRecordset rs
Now all I wanted to do is to connect DB without having client installed in my machine. Can any one pls guide me
I have successfully connected excel to SQL developer using the below VBA code. I have oracle client and oracle dc drive in my machine.
Dim con As ADODB.connection
Dim rs As ADODB.Recordset
Dim Cmd As New ADODB.Command
Dim query As String
Dim strsql As String
Dim a As Integer
'Dim db As Dao.Database
Set con = New ADODB.connection
Set rs = New ADODB.Recordset
Application.ScreenUpdating = True
Cmd.CommandType = adCmdText
'--- Replace below highlighted names with the corresponding values
strCon = "Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=hostname)(PORT=portnum))" & _
"(CONNECT_DATA=(SERVICE_NAME=ser_name))); uid=username; pwd=password;"
'--- Open the above connection string.
con.Open (strCon)
***sql query*****
rs.Open strsql, con
Sheets(1).Range("A2").CopyFromRecordset rs
Now all I wanted to do is to connect DB without having client installed in my machine. Can any one pls guide me