Error joining tables from separate db's using SqlCommand object

C

Corbin

I'm trying to run a query that joins tables from 2 databases on the
same server. The query is like this:

SELECT TitleID, u.Name as Assignee
FROM tblTitle t
LEFT JOIN titlepost..Portal_Users u
ON t.TitleProcessor = u.email

When I put it in a stored procedure and execute the sp using SqlCommand
object, there are no problems. But I need to be able to run this query
using the CommandText property rather than by calling a stored
procedure. When I attempt this, I get "Invalid object name
'titlepost.dbo.PortalUsers'". My connection string is
"server=10.10.10.10;Trusted_Connection=true;database=abstractors"
Any suggestions are appreciated.

Corbin
 
E

Elton Wang

Check out the permissions for table titlepost..PortalUsers.

Elton Wang
(e-mail address removed)
 
C

Corbin

Thats not it. I query from this table all the time, both within my
application and through query analyzer, using the same trusted
connection. The only difference in this situation is that I'm trying
to do dynamic sql instead of a stored procedure.
 
E

Elton Wang

In my experience, if using correct connectionstring, i.e.,
uid=sa;pwd=password, there is no any trouble to conduct
any join query from different databases.

Elton Wang
(e-mail address removed)
 
E

Elton Wang

BTW, is the owner of table Portal_Users dbo? If the owner
is not dbo, you have to name it
titlepost.OwnerName.Portal_Users. The
titlepost..Portal_Users means titlepost.dbo.Portal_Users.

Hope it helps,

Elton Wang
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top