468,770 Members | 2,388 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,770 developers. It's quick & easy.

HELP, Create Table o the fly from dataset

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
Nov 16 '05 #1
2 5857
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

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Paul Oliveira" <Pa**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
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


Nov 16 '05 #2
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

"Paul Oliveira" <Pa**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
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....Im complety
lost

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Graham Pengelly | last post: by
6 posts views Thread by Chad A. Beckner | last post: by
4 posts views Thread by steroche | last post: by
reply views Thread by Rogelio Moreno | last post: by
2 posts views Thread by rufpirat | last post: by
9 posts views Thread by Tony Girgenti | last post: by
15 posts views Thread by Jay | last post: by
1 post views Thread by =?Utf-8?B?RGFuIFNoZXBoZXJk?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.