Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

Database question (begginer)

I have delphi 3.0 and i need to know which components do I need to use to compare two databases *.dbf .I need to compare two fields from different databases.
0
Dark_Man
Asked:
Dark_Man
1 Solution
 
Oli2Commented:
Just use two TTables.

var: nmatch : Integer;
while ( not Table1.EOF ) or ( Table2.EOF ) do
begin
if Table1.Fields[3].AsString = Table2.Fields[9].AsString then inc ( nmatch );
Table1.Next;
Table2.Next;
end;

This would compare the 3rd Field of Table1 with the 9th Field of Table2.
It would compare it record for record tough.

Is that what you needed ?

Greetings, Oli
0
 
martin_gCommented:
You need to first have two table components (and two datasource components attached to those tables if you are going to display the information).

For example:
Table1 with DataSource 1
Table2 with DataSource 2

Now for some code:

Table1.Open;  {activate the table and go to the first field}
Table2.Open;
if Table1FIELDTOCOMPARE.Value = Table2.FIELDTOCOMPARE.Value then
  do something; {this compares the values of the fields "FIELDTOCOMPARE" in the first record of TAble 1 and Table2}

If you need to find a value (such as a lookup table or need to loop through a table, let me know and I'll show you how).

Hope this will get you started.



0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now