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
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