469,922 Members | 2,172 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

2 tables, compare data help??

by m.r.davies
I have 2 tables on seperate Db's (and servers)
I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB
when i have the correct row in the 2nd DB I want to compare each field in the 2 tables to see if they match

Every time i try and think how i end up with a while loop for the reader on table1 and a while loop for the reader on table 2

any ideas how i'm going to do this?
Cheers
Nov 18 '05 #1
1 1743
i assum that both the tables on db1 and db 2 have a common id.
say you want to get booking info from table 1 and then compare it to the
booking ref in table 2 in db2.
use a stored proc and get the record info. Not a big fan of datareader as
its not disconnected... rather prefer
output parameters if my stored proc returns only one row or a dataset if my
proc returned more than one records..
disconnect the dataset or read the output params into a custom bookingInfo
object

next fire up another query which will take the booking id (from dataset or
custom object you populated from output parameter) and return any
corresponding data from table2 in db2
if you expect more than one value again.. use a dataset or if only one then
user output parameters of stored procs

now you have two objects or two datasets and you just need to iterate them
both to compare corresponding column values

Hope this helps,

--

Regards,

HD
"Mark" <an*******@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
by m.r.davies
I have 2 tables on seperate Db's (and servers)
I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB when i have the correct row in the 2nd DB I want to compare each field in the 2 tables to see if they match
Every time i try and think how i end up with a while loop for the reader on table1 and a while loop for the reader on table 2
any ideas how i'm going to do this?
Cheers

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jandre | last post: by
3 posts views Thread by Random Person | last post: by
3 posts views Thread by Michael Thomas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.