Refresh of ADOTable after Cascaded Delete

  I have a MS Access database (older .mdb file) that has relationships defined which includes cascaded deletes. I am using ADOTable components (because I grew up on BDE and am now an old dog) where I delete a record in table A and it cascades down and deletes a record in table B automatically.

 My code knew that the Table B record needed to be deleted but it does not know this record in Table B was deleted through the cascade.

 I have a MYID primary key in table B and var myidnum has the number of the TableB Primary Key I wish to delete.

 I wrote:
       If TableB.Locate (['MYID',myidnum,[]) 
            Then TableB.Delete;

 The Locate returns True but I get an  EOleException on the Delete as the record can not be found.

I tried a TableB.Refresh before the Locate but that did not help.

What fixed the problem was:
    TableB.Active := False;
    TableB.Active := True
    If TableB.Locate('MYID',myidnum,[]) 
         Then TableB.Delete;

With the toggle of the Active property the Locate fails, the .Delete method is never called, and life is good..


  Is there anything more "Correct" than the toggle of .Active?

  Any general descriptions of what is going on and maybe causing problems? (Like maybe cursors?)

Bob K.
6/30/2015 12:34:06 AM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 45


Similar Artilces:

Cascading deletes - Which is better
I need to implement my cascading deletes on a SQL database.  Is it better (performance/reliablility-wise) to use the Foreign Key Cascading Deletes or to just write my own triggers to do the deletes?I was hoping someone had experimented and found which works best. DRI(declarative referential integrity) triggers are used when Cascade Deletes and Updates cannot be implemented in the RDBMS(relational database management system) as in SQL Server 7.0 and below.  In SQL Server 2000 using Cascade Delete and Cascade Update is the way to go.  The reason is reliability related because ...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC ( - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Delphi 6 to Delphi 2010 upgrade and ADO
We have an application written in Delphi 6 Professional that uses ADO to access databases servers that may be on other PCs in our network. We want to move to Delphi 2010 but can't decide if we need Professional or Enterprise. 2010 Pro has dbGO - will this give us the same functionality as the ADO components we use in Delphi 6 Pro? Thanks, Keith > 2010 Pro has dbGO - will this give us the same functionality as the > ADO components we use in Delphi 6 Pro? Yes. > {quote:title=Joachim Uersfeld wrote:}{quote} > > 2010 Pro has dbGO - will this give us the same func...

GridView is not Refreshing after deleting record. How do i make it refresh.
I created a page where i have GridView and a DetailView.  The DetailView is filled using the GridViews key as parameter.  But after I finish doing any update nither the GridView nor the DetailView refreshes the changes.  What am I missing?   Thanks for any suggestions? First, verify that your database doesnt actually still contain the record your trying to delete.  It's very common to assume that the record was deleted, when in fact it still exists. Second, check caching, if your doing web caching, your not going to be hitting the database each time the page rel...

Is Cascading deletes prefered to deleting thru a stored procedure?
I have a situation in which I have three tables - 'Table1', 'Table2' and 'Table3'. 'Table1' is a primary table for 'Table2' so that the the primary key of 'Table1' is a foreign key in 'Table2'. In the same way, 'Table1' is also the primary table for 'Table3'. If I delete a row in 'Table1' then I could automatically let SQL Server also delete the related rows in 'Table2' and 'Table3' through 'cascading delete' option. Or I could run a trigger or stored procedure for deleting related rows in 'Table2' and 'Table3'. Which of these methods would be quicker? Also would cascading deletes option a...

ASA7 ADO & Delphi ADO ?? Anyone is using it?
Any comments? Is it working? Any Problems? Thanks Hi, PR <> schrieb in im Newsbeitrag: BoTThJaq$ > Any comments? Is it working? Any Problems? I tried to connect to ASA7 via the new OLE DB - Provider and ADOExpress from Delphi 5.01. No chance. Only the error message 'Invalid Enum Value'. About the new provider I haven't heard anything good until now... Regards Frank Frank, I've experienced the same problem with the ASA 7 OLEDB Provider. I'm not sure if this is a bug in the AsaProvider or Delp...

Cascading deletes
Thanks. So I understand that there is currently no cascading deletes in MS SQL Server and you implement it using triggers or similar. Correct. There is a LOT of stuff missing from MS SQL Server. You will be much happier with SQL Anywhere. Breck On Tue, 26 Dec 2000 11:23:39 -0800, "Anand" <> wrote: >Thanks. So I understand that there is currently no cascading deletes in MS >SQL Server and you implement it using triggers or similar. > ...

cascade delete
Does anyone know how to implement cascade delete within ASE on tables with foreign keys? If so please help me! I know that ASA has this capability but I can not find anything in ASE to support it. Here is my email if you have an answer thanks, Richard ASE does not support declarative cascading deletes through referential integrity. If you want to do cascading deletes, you will have to write triggers to handle your foreign keys, rather than using the constraints. -bret Rich and Peg wrote: > Does anyone know how to implement cascade dele...

On delete cascade
I faced this issue when using ON DELETE CASCADE functionality. Please let me if this can be termed as a bug. create table test( num integer, primary key (num) ); create table test_assoc( num1 integer, num2 integer, primary key(num1, num2), foreign key num1 references test(num) on delete cascade, *-- NOTE: CASCADE is specified here.* foreign key num2 references test(num) on delete cascade, ); My assumption was if i delete any row from the test table, then all the rows which are affected by this will get deleted automatically from the tes...

Refresh does not refresh
Name: Udo Steinbach Email: usenetatudolinedotde Product: Firefox Summary: Refresh does not refresh Comments: I had build some SVG and inserted them with <a href="xxx.html"><object data="xxx.svg" type="image/svg+xml" style="..."><img src="xxx.png" style="..."/></object> other text</a> in one file, several graphics every multiple times. Firefox showed the page correct. Because I forgot a point to insert a graphic I edited the file again, and then pressed F5 (refresh) in Firefox to display ...

Cascading deletes
Were using these right? Noticed that there is no DeleteBooks method, but a delete contentPage method - I swear to god that we need to have a ContentItem class - I know there is a ContentItem class defined under that darn ContentList repeater, But I renamed mine to ContentItemContainer I think that we should have a Content Item table in the DB the HorrorGet ready to blast your energy levels into high gear with Sedgewick Energy Drink. High powered adaptogenic herbs mixed with potent levels of B-vitamins and...Please disregard the contents of this post....

refresh after delete
I have created a delete button with a conformation step. The delete button deletes a record from the db.The delete works fine but the record doesn't dissapear until i refresh the page... how can i acheive this? Ilan Ilan Perezweb Developer | Designer This is probably due to the data bound control not being "re-bound" on postback. The easiest way to achieve this is to call you delete method then at the end of the delete method call the rebind the control with the new dataset. Try that out, if it doens't work what are using for your data container? Sql Server, Ac...

delete cascade
I'm trying to add delete cascade to an already-existing table via ISQL. I'm getting a syntax error: alter table carrier on delete cascade; Error = syntax error near 'on' Should I be able to do this? I'm running on Windows 2000 Pro, SQLAnywhere 5.5.03, using DBENG50.EXE. It should be something like: alter table carrier drop foreign key fk1 alter table carrier add foreign key fk1 references ... etc ... on delete cascade Then when the row in the fk1 table is deleted the row in the "carrier" table will be deleted also. -- Steve http://www...

Cascade delete
Is there an 'add-on' to ASE that adds cascade delete functionality? (parent-child situations.) To avoid writing triggers for each table? Thanks. > Is there an 'add-on' to ASE that adds cascade delete > functionality? (parent-child situations.) To avoid writing > triggers for each table? No - there is no cascade delete functionality within ASE. Michael I suppose an 'sp_delcade' procedure could be written... :) > > Is there an 'add-on' to ASE that adds cascade delete > > functionality? (parent-child situations.) To avoid ...

Web resources about - Refresh of ADOTable after Cascaded Delete - embarcadero.delphi.ado

var Item1 : TTreeViewItem; Item2 : TTreeViewItem; begin Item1 := TTreeView -
var Item1 : TTreeViewItem; Item2 : TTreeViewItem;begin Item1 := TTreeViewItem.Create(Self); Item1.Text := 'My First Node'; Item1.Parent := TreeView1; ...

Resources last updated: 12/7/2015 11:45:41 PM