how to pull/query data from 2 Databases into 1 table using .Net?

G

Guest

Hello,

I need to pull data from 2 tables that reside on the same sql server but 2
different databases. In Query Analyzer I can say this

select t1.*, t2.* from tbl1 t1 join database2.dbo.tbl1 t2 on t1.RecordID =
t2.RecordID

The .Net sql command object does not appear to support this kind of syntax.
I need to populate one datagridview with the data from DB1.tbl1 and
DB2.tbl1. Is there a way to do this?

Thanks,
Rich
 
G

Guest

Well, it turns out that the Sql Command object does support this kind of
syntax. It seems that I left out the reference to DB2 in my sql string.
Bummer man!
 
L

Liz

Rich said:
Hello,

I need to pull data from 2 tables that reside on the same sql server but 2
different databases. In Query Analyzer I can say this

select t1.*, t2.* from tbl1 t1 join database2.dbo.tbl1 t2 on t1.RecordID =
t2.RecordID

The .Net sql command object does not appear to support this kind of
syntax.

why not ? what does it do ?
 
G

Guest

I made a mistake. The sql command does support select t1.*, t2.* from tbl1
t1 join DB2.dbo.tbl1 t2 on t1.RecID = t2.RecID

My app works now.
 

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