Compare the similarities and differences between data tables in the two access databases based on the ID field

Source: Internet
Author: User

// Function Description: Compares the similarities and differences between data tables in two access databases based on the ID field
// The first database of P1
// P2 second database
// Tname name of the data table to be compared
Function comprecordbyid (adoquery: tadoquery; P1, P2, tname: string): Boolean;
VaR
Sqlstr: string;
Begin
Sqlstr: = 'select * from ('+
'Select t1.id, t2.id from ['+ p1 +']. '+ tname + 'as T1 left join' + tname + 'as T2 on t1.id = t2.id' +
'Union '+
'Select t1.id, t2.id from ['+ p1 +']. '+ tname + 'as T1 right join' + tname + 'as T2 on t1.id = t2.id' +
')' +
'Where t1.id is null' + // records not found in the first database
'Or t2.id is null'; // records not found in the second database

Adoquery. close;
Adoquery. connectionstring: = 'provider = Microsoft. Jet. oledb.4.0; Data Source = '+ p2 +'; persist Security info = false ';
Adoquery. SQL. Text: = sqlstr;
Adoquery. open;
End;

The above function has a bug. Please refer to another article.Article
Http://blog.csdn.net/siow/archive/2008/05/29/2493944.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.