Cursor not returned from Query
Posted: Mon 28 Mar 2005 21:39
I am copying selected records from one table to another. Prior to starting the copy, I first 'delete from table-name'. I do this with the SQL string of my TSQLQuery object. When I set this object 'Active', I get theerror message 'Cursor not returned from Query'. It looks like I should be using 'ExecSQL' but that gave me the same error.
Procedure follows:
===========================================================================================
Is there another object I should be using?
Any suggestions on the code issue.
Thanks in advance
udstx
Procedure follows:
=============================================
Code: Select all
procedure TFrmMain.Mk_demo();
begin
log.Lines.Add('Create Demographics for '+srvcat_);
// clear demographis table
CDS_demo.Active := false;
sql_ := 'delete from demographic';
SQL_demo.SQL.Clear;
SQL_demo.SQL.Add(sql_);
try
SQL_demo.ExecSQL(true);
{ SQL_demo.Active := true;
sleep(2000);
}
except
// do nothing
end;
CDS_demo.Active := true;
// reload the demographics table
// CDS_demo.Open;
DBGrid1.DataSource := DS_demo;
While not CDS_gwc.Eof do
begin
CDS_demo.Append;
CDS_demo.FieldByName('client').Value := CDS_gwc.FieldByName('client').AsInteger;
CDS_demo.FieldByName('SrvCat').Value := CDS_gwc.FieldByName('SrvCat').AsString;
CDS_demo.FieldByName('Dos').Value := CDS_gwc.FieldByName('Dos').AsDateTime;
CDS_demo.FieldByName('Mos').Value := CDS_gwc.FieldByName('Mos').AsString;
CDS_demo.FieldByName('age').Value := CDS_gwc.FieldByName('age').AsString;
CDS_demo.FieldByName('race').Value := CDS_gwc.FieldByName('race').AsString;
CDS_demo.FieldByName('sex').Value := CDS_gwc.FieldByName('sex').AsString;
CDS_demo.FieldByName('city').Value := CDS_gwc.FieldByName('city').AsString;
CDS_demo.FieldByName('cnty').Value := CDS_gwc.FieldByName('cnty').AsString;
CDS_demo.FieldByName('zip').Value := CDS_gwc.FieldByName('zip').AsString;
CDS_demo.UpdateRecord;
CDS_gwc.Next;
end;
CDS_demo.ApplyUpdates(1);
sql_ := 'select * from demographic order by cnty,city,zip';
CDS_demo.Active := false;
SQL_demo.SQL.Clear;
SQL_demo.SQL.Add(sql_);
SQL_demo.Active;
CDS_demo.Active := true;
end;
Is there another object I should be using?
Any suggestions on the code issue.
Thanks in advance
udstx