Friday, February 10, 2012

Can't connect ODBC/SQLSrvr linked table from within COM+ component

I have an Access 2000 database containing an ODBC table linked to a SQL Serv
er 2000 database (using a system DSN).
No problem opening the table Using Access 2000 itself.
No problem even within a VB program (EXE) accessing that table using the fol
lowing code:
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cnSrc
.Source = "SELECT * FROM " _
& "[ODBC;" & tbODBC.Properties("Jet OLEDB:Link Provider String") & "]."
_
& tbODBC.Name & vbCrLf & "WHERE FALSE"
.CursorLocation = adUseServer
End With
On Error Resume Next
rs.Open ' <-- ERROR RAISES HERE
cnSrc is an ADO Connection with Access2000 DB
tbODBC is an ADOX Table object corresponding to the linked ODBC table
But if the same code is placed in a COM+ component (DLL ActiveX), once invok
ed by any client, when the final "rs.Open" is executed, the following error
raises:
"Connection to <sql server database name> failed"
Number = 0x80004005
SQLState = 3151
I've searched many places but with no results.
Some help will be appreciated.
Thanks in advance
RafThe Jet OLEDB provider does not support distributed transactions since it
does not implement the ITransactionJoin OLE-DB interface.
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2004 All rights reserved.
"Raf" <anonymous@.discussions.microsoft.com> wrote in message
news:0377EFF9-6D50-447F-B38F-779100742A52@.microsoft.com...
>I have an Access 2000 database containing an ODBC table linked to a SQL
>Server 2000 database (using a system DSN).
> No problem opening the table Using Access 2000 itself.
> No problem even within a VB program (EXE) accessing that table using the
> following code:
> Set rs = New ADODB.Recordset
> With rs
> .ActiveConnection = cnSrc
> .Source = "SELECT * FROM " _
> & "[ODBC;" & tbODBC.Properties("Jet OLEDB:Link Prov
ider
> String") & "]." _
> & tbODBC.Name & vbCrLf & "WHERE FALSE"
> .CursorLocation = adUseServer
> End With
> On Error Resume Next
> rs.Open ' <-- ERROR RAISES HERE
> cnSrc is an ADO Connection with Access2000 DB
> tbODBC is an ADOX Table object corresponding to the linked ODBC table
> But if the same code is placed in a COM+ component (DLL ActiveX), once
> invoked by any client, when the final "rs.Open" is executed, the following
> error raises:
> "Connection to <sql server database name> failed"
> Number = 0x80004005
> SQLState = 3151
> I've searched many places but with no results.
> Some help will be appreciated.
> Thanks in advance
> Raf
>

No comments:

Post a Comment