
ODBC Connection failed when using OPENROWSET
Hi all,
I'm trying to run this code below but keeping getting an error. I also
tried to create a storedProcedure with the same SQL but I get the same
error.
The DB is SQLSERVER7 with a machine DSN setup on my workstation called
AUCTION_ORACLE_WEB. The OPENROWSET works great within TSQL but not within
my VB6 app.
----------------------------------------------------------------------------
----
OPENSQLSERVER
'Oracle
Tx = "SELECT distinct(LastFirst) FROM
OPENROWSET('MSDAORA','PTADEV';'WEBAUC';'WEBAUC',"
Tx = Tx & " " & Chr(34) & "Select * from Auction_win_tbl where
remoteusername='LocalUser'"
Tx = Tx & " order by netid" & Chr(34) & ")A,"
Tx = Tx & " userinfo_view B where A.netid=B.netid order by lastfirst"
'In Oracle you can not open two tables from different servers. So instead I
elected to bring back
'all active employees regardless if they won samples or not
'Tx = "Select * from UserInfo_View where status='A' order by NETID"
'Tx = "AUCTION_WINNER_NAMES"
If CnSQL.StillExecuting = False Then
Set QrSQL = Nothing
Set RS2 = Nothing
Set QrSQL.ActiveConnection = CnSQL
End If
QrSQL.SQL = Tx
Set RS2 = QrSQL.OpenResultset(rdOpenKeyset, rdConcurBatch)
----------------------------------------------------------------------------
-----
But keep getting this error:
----------------------------------------------------------------------------
-----------
Error 40002: 37000: [Microsoft][ODBC SQL Server Driver][SQL Server]Ad hoc
access to OLE DB provider 'MSDAORA' has been denied. You must access this
provider through a linked server.
----------------------------------------------------------------------------
-----------
Any help would be appreciated. Thanks.