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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO UPDATE RECORDS WITH ADO COMPONENTS ?

Status
Not open for further replies.

selena1

Programmer
Apr 7, 2003
69
For work with my database I use ADO components. Everything work fine when I use ADOTable or ADOQuery to retrieve records from one table. But when I use ADOQuery to retrieve records from two or more tables I can't update records after I had changed them. I get error: "Insufficient inforamtions for update." .Or something like that. So, how can I update records from more than one tables ? Problem is that ADO components don't have component ADOUpdateQuery, like TUpdateQuery on BDE page.

Thanks!
 
I think the answer is you have to do a bit more coding yourself, updating each table separately. I find that every since I wrote an Intranet system (where TUpdateSQL couldn't be used), I have more and more been writing my own SQL statements both to retrieve data and update it.

Thus:

with dmRnDProject.quRndUpdate do begin
commandtext := 'Delete from Milestones where Milestone_ID = '
+ IntToStr(dmRndproject.quMilestone.FieldByName('Milestone_ID').asInteger);
execute;
end;

Or:

with qugeneral do begin
if active then close;
SQL.clear;
SQL.add('SELECT Address_ID, Pur_Contact_ID, Date FROM PurchContactSheet ');
SQL.add('WHERE Address_ID = :Address_ID ORDER BY Pur_Contact_ID, Date');
Parameters.ParamByname('Address_ID').value:= FAddress_ID;
open;
end;

The more you do this, the quicker you get at it.

|Best of luck.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top