cipcip said:
Is it possible to connect to 3 database and execute a cross db query?
I usually use SqlConnection(connectionString) for a single connection
Yes. Connecting to sqlserver is a 2-step process. First you connect
to the sqlserver process by the credentials given (either in the
connection string or through windows authentication). That's step 1.
Then you will connect to the catalog you've specified in the connection
string. That's step 2. If you don't have access rights to the catalog
specified, you won't be able to make step2 even if you made step 1.
Once connected to a sqlserver process, you can in theory access every
catalog in the system you have access rights to. So if you're connected
to catalog 'Northwind' and you want to join customers in northwind with
pubs' authors table, you can do something like:
SELECT * FROM northwind.dbo.customers c inner join pubs.dbo.authors a
ON ...
So you have to specify the catalog, schema and table name, not just
the tablename, but that's logical, as otherwise sqlserver thinks the
table is in the catalog you connected to in step2.
Frans
--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website:
http://www.llblgen.com
My .NET blog:
http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------