ODBC Connection to Oracle - prompting for Server Name

dmcgimpsey

Active Member
Joined
Mar 30, 2004
Messages
268
Hi Folks:

I have a VBA script that communicates with Oracle - when I click on the refresh button, a dialog box pops up and asks for the Server Name .... I was wondering if I can pass this variable to the connection instead of having the users have to enter it each time - the problem is that they likely don't even know what the server name is.

Thanks

Don

Query is below:


If global_username = "" Then Call password_entry

strConOracle = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) "
strConOracle = strConOracle & "(HOST=" & HOST & ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=" & DBNAME
strConOracle = strConOracle & " ))); uid=" & ORACLE_USER_NAME & " ;pwd=" & ORACLE_PASSWORD & ";"

Set oConOracle = CreateObject("ADODB.Connection")
qstr = " Select * from query_result "

oConOracle.Open strConOracle

splitsql = SplitString(qstr)

' On Error Resume Next

With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = "OLEDB;" & oConOracle
.CommandType = xlCmdSql
.CommandText = splitsql
.CreatePivotTable TableDestination:= _
"'[ABCHAMP_resp_prof_JUL10 v17.xls]MainMenu'!R23C3", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
End With
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,793
Office Version
  1. 365
Platform
  1. Windows
Is that a variable called HOST being inserted into the connection string? Is that where the name of the server goes? What's the value of the variable HOST when you create the connection?
 

dmcgimpsey

Active Member
Joined
Mar 30, 2004
Messages
268
it contains the correct parameter for the HOST connection. This problem seems to happen when I pass the record set to Excel Pivot table, but does not prompt me at other points.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,208
Messages
5,857,918
Members
431,907
Latest member
RNN

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
Top