HELP, Create Table o the fly from dataset

G

Guest

Bear with me, please... :)

TableA on Database1:
CodCli -- Name -- Age -- SalesCod
(...) (...) (...) (...)

TableB on Database2:
Key -- CodCli -- Date -- Value
(...) (...) (...) (...)

[Using Vs 2003.net Crystal Report]

We need to see and print all rows from TableB that as the SalesCod = "user
input".
Something like:
Select CodCli from TableA where SalesCod= "User Input" and (select * from
tableB
I can not do this because the tables are in diferent databases :(((

My solution:
1) Create 2 datasets from tableA and TableB
2) Create on the fly 1(one) table in the database, that as the information
from the two tables.(put the 2 datasets into the table).
3) create a new dataset from the new table and then query this new table.

I have no idea on how to implement point 2).

If anyone has o new idea please point me in the right way....I´m complety
lost
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Paul,

Actually, you can include tables from different databases into a single SQL
statement. You will only have to add the database names to the table names:

SELECT Database1.TableA.CodCli From Database1.TableA Where
Database1.TableA.SalesCod = "User Input" INNER JOIN Database2.TableB ON
Database1.TableA.CodCli = Database2.TableB.CodCli
 
M

mortb

If the tables are in different databases but on the same sever

You could query the tables:

Select * from databaseA.dbo.TableA as tbla

Inner join databaseB.dbo.TableB as tblb on tbl1.codcli = tbl2.codcli

Otherwize you select what you want from the first table into a dataset and
what you want from the second table into another and then loop through them
and add rows from to the first from the second

I don't think that creating a new table is what you want as it would be
harder to ensure concurrency between the tables.

Cheers,

mortb
 

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