jennifere
asked on
Post data to a table
I am trying to post data and update a table as I am running through a loop. I have already done table.edit and table.post. However, when the loop gets to table.post, it displays an error message that says my dataset is not in edit or insert mode. Is there a way to post data to a table each time my program executes through a loop??
while not (tblAgents.Eof) and (x < 51) do
begin
edtSearch.Text := 'SHAFERJO';
tblAgents.SQL.Clear;
tblAgents.SQL.Add('Select * from Agents where AgentId = '+QuotedStr( startHere ) );
tblAgents.Active := True;
strEmail := tblAgents.fieldbyname('Ema il').AsStr ing;
strAgentId := tblAgents.fieldbyname('Age ntId').AsS tring;
strEmailStatus := tblAgents.fieldbyname('Ema ilStatus') .AsString;
strVerifiedDate := tblAgents.fieldbyName('Ema ilVerified ').AsDateT ime;
if (x = 50) then
if (strEmail <> '') then
begin
//Validate to SMTP level
iRating := con.Validate(strEmail, hexVeLevelSmtp);
//If address is bad
if (hexVeLevelBad = iRating) then
begin
error := GetErrorString(con.Error);
if (strEmailStatus = '1') then
tblAgents.Fieldbyname('Ema ilStatus') .AsString := '2';
if (strEmailStatus = '2') then
tblAgents.FieldByName('Ema ilStatus') .AsString := 'I';
//Address is good
else
tblAgents.FieldByName('Ema ilStatus') .AsString := 'V';
tblAgents.Edit;
tblAgents.Post;
end;
tblAgents.Next;
x := x + 1;
end;
while not (tblAgents.Eof) and (x < 51) do
begin
edtSearch.Text := 'SHAFERJO';
tblAgents.SQL.Clear;
tblAgents.SQL.Add('Select * from Agents where AgentId = '+QuotedStr( startHere ) );
tblAgents.Active := True;
strEmail := tblAgents.fieldbyname('Ema
strAgentId := tblAgents.fieldbyname('Age
strEmailStatus := tblAgents.fieldbyname('Ema
strVerifiedDate := tblAgents.fieldbyName('Ema
if (x = 50) then
if (strEmail <> '') then
begin
//Validate to SMTP level
iRating := con.Validate(strEmail, hexVeLevelSmtp);
//If address is bad
if (hexVeLevelBad = iRating) then
begin
error := GetErrorString(con.Error);
if (strEmailStatus = '1') then
tblAgents.Fieldbyname('Ema
if (strEmailStatus = '2') then
tblAgents.FieldByName('Ema
//Address is good
else
tblAgents.FieldByName('Ema
tblAgents.Edit;
tblAgents.Post;
end;
tblAgents.Next;
x := x + 1;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Of course... that makes sense. Thanks-- and sorry for the stupid question. :)
NP - remember - no question is stupid question? We have all made those mistakes!
Shane
Shane
begin
edtSearch.Text := 'SHAFERJO';
tblAgents.SQL.Clear;
tblAgents.SQL.Add('Select * from Agents where AgentId = '+QuotedStr( startHere ) );
tblAgents.Active := True;
strEmail := tblAgents.fieldbyname('Ema
strAgentId := tblAgents.fieldbyname('Age
strEmailStatus := tblAgents.fieldbyname('Ema
strVerifiedDate := tblAgents.fieldbyName('Ema
if (x = 50) then
if (strEmail <> '') then
begin
tblAgents.Edit;
//Validate to SMTP level
iRating := con.Validate(strEmail, hexVeLevelSmtp);
//If address is bad
if (hexVeLevelBad = iRating) then
begin
error := GetErrorString(con.Error);
if (strEmailStatus = '1') then
tblAgents.Fieldbyname('Ema
if (strEmailStatus = '2') then
tblAgents.FieldByName('Ema
//Address is good
else
tblAgents.FieldByName('Ema
tblAgents.Post;
end;
tblAgents.Next;
x := x + 1;
end;