ODBC Connect Via Macro

JShaper

New Member
Joined
Oct 19, 2009
Messages
19
I wish to import a Oracle table via a macro and have done it via the wizzard and recorded that. when i run it i get a 1004 error at the refresh. I then scripted it myself and it fails at the connect line. Can you help me please. I got the driver from a record macro script...

My script:

Dim oConn As Object, oRS As Object
Password = InputBox("input password", "enter password")
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "Driver={Oracle ODBC Driver};" & _
"Dbq=RPTCCB;" & _
"Uid=JSHAPER;" & _
"Pwd=" & Password

Set oRS = CreateObject("ADODB.RecordSet")
oRS.Open "SELECT SC_ACCESS_CNTL.USR_GRP_ID, SC_ACCESS_CNTL.APP_SVC_ID, SC_ACCESS_CNTL.ACCESS_MODE, SC_USR_GRP_PROF.EXPIRATION_DT, SC_ACCESS_CNTL.VERSION, SC_ACCESS_CNTL.OWNER_FLG FROM CRYSTAL.SC_ACCESS_CNTL SC_ACCESS_CNTL, PRDCCB01.SC_USR_GRP_PROF SC_USR_GRP_PROF WHERE SC_ACCESS_CNTL.APP_SVC_ID = SC_USR_GRP_PROF.APP_SVC_ID AND SC_ACCESS_CNTL.USR_GRP_ID = SC_USR_GRP_PROF.USR_GRP_ID", oConn

Range("A1").CopyFromRecordset oRS

Thank you in advance to anyone that spends any time helping me figure this out...
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I can't seem to edit my post so here is the correct open statement I forgot i edited it from a test file for some reason.

oConn.Open "Driver={Oracle in OraClient10g_home1};" & _
"Dbq=RPTCCB;" & _
"Uid=JSHAPER;" & _
"Pwd=" & Password

This is also the line when i go line by line it bugs out and gives me runtime error
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top