-
Hi Sarat,
Here is code just copy and paste in new module
[VBA]Sub connectDB()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strHost, strDatabase, pwd, strUser, strPassword As String
Set conn = New ADODB.Connection
strHost = "localhost"
strDatabase = "ORCL"
strUser = "HR"
strPassword = "password"
conn.ConnectionString = "Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=" & strHost & ")(PORT=1521))" & _
"(CONNECT_DATA=(SERVICE_NAME=" & strDatabase & "))); uid=" & strUser & " ;pwd=" & strPassword & ";"
conn.CommandTimeout = 100000
conn.Open
Set rs = New ADODB.Recordset
rs.Open "Employees", conn, adOpenKeyset, adLockBatchOptimistic
ActiveCell.CopyFromRecordset rs
conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules