Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOTable Edit - Post problem

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
I have a simple procedure that compares e-mails in two different databases and places an X in a field of one database if the e-mails match. Here is my code and an error message.

With ADOTable1 do
begin
While NOT EOF do
begin
Email := FieldByName('Email').AsString;
With ADOTable2 do
begin
while NOT EOF do
begin
EmailBDE := FieldByName('Email').AsString;
if Email = EmailBDE
then
edit;
ADOTable2.FieldByName('New').AsString := 'X';
post;
next;
end;
end;
next;
end;
end;

Error: ADOTable2: dataset not ib edit or insert mode.

What is my problem and what is the solution?
 
This kind of operation is very simple if you use SQL.

Suppose your two databases are called A and B and the two tables you are comparing are called emails then the SQL to do what you want is something like:
Code:
UPDATE A.emails, B.emails
SET A.emails.new='X'
WHERE A.emails.Email = B.emails.Email

It will probably be quicker than the code you've written as well (especially if the databases are on a different computer).

However, if you insist on using your own code then I suggest you make the update code a compound statement:
Code:
         if Email = EmailBDE 
          then [red] 
            begin [/red]
            edit;
            ADOTable2.FieldByName('New').AsString := 'X';
            post;
            [red]end;[/red]

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top