harwooddale
Programmer
Hi,
I am trying to query an oracle database using ODBC.
I am passing an input variable from an input box to the
sql and it fails when I reaches the refresh background query line.
Any Ideas?
The code I am using is
Dim Message, Title, Default, MyValue
Message = "Enter the Table to query" ' Set prompt.
Title = "InputBox" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DRIVER={Oracle in ORACLE901i};SERVER=SERVER;UID=USER;PWD=PASSWD;DBQ=DBQ;DBA=W;APA=T;EXC=F;XSM=Defaul" _
), Array( _
"t;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BAM=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=10;TLO=O;" _
)), Destination:=Range("A1"
)
.Sql = Array("select * from " & MyValue & " ;"
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=True
.SavePassword = True
.SaveData = True
End With
End Sub
Thanks in advance
James
I am trying to query an oracle database using ODBC.
I am passing an input variable from an input box to the
sql and it fails when I reaches the refresh background query line.
Any Ideas?
The code I am using is
Dim Message, Title, Default, MyValue
Message = "Enter the Table to query" ' Set prompt.
Title = "InputBox" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DRIVER={Oracle in ORACLE901i};SERVER=SERVER;UID=USER;PWD=PASSWD;DBQ=DBQ;DBA=W;APA=T;EXC=F;XSM=Defaul" _
), Array( _
"t;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BAM=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=10;TLO=O;" _
)), Destination:=Range("A1"
.Sql = Array("select * from " & MyValue & " ;"
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=True
.SavePassword = True
.SaveData = True
End With
End Sub
Thanks in advance
James