Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

[SOLVED] Store values in Excel Sheets from Database using macro code

$
0
0
I have a code which connects to the Oracle Database, in that code i am executing a sql which will fetch data from a table.
I would like to store the values from all the columns in Sheet2. Kindly help me on the code.
Code:

Sub Ora_Connection()

Dim sourceCnn As ADODB.Connection
Dim sourceRst As ADODB.Recordset

Set sourceCnn = New ADODB.Connection
Set sourceRst = New ADODB.Recordset

strCon = "Provider="";User ID="";Password="";Data Source="""
 
sourceCnn.Open (strCon)
sourceRst.ActiveConnection = sourceCnn

sourceRst.Source = " SELECT * FROM TABLE"
sourceRst.Open

MsgBox "Connected Successfully", vbOKCancel

End Sub


Viewing all articles
Browse latest Browse all 50061

Trending Articles