By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

2 tables, compare data help??

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.