ado .delete deletes joined table records?

ado .delete deletes joined table records?

Post by Bill » Wed, 15 Jan 2003 13:13:11



Because ADO could not correctly figure out how to construct the DELETE
query?
Try to use this instead:

SELECT T1.Field1, T1.Field2,
               T2.Field1
                FROM T1, T2 WHERE T1.IdField  = T2.IDField

Sometimes this helps.

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________


Quote:> I need help. Badly. I have a SQL query that joins a couple of tables
> together
> like so:

> SELECT T1.Field1, T1.Field2,
>                T2.Field1
>                 FROM T1 LEFT JOIN T1 ON T1.IDField = T2.IDField

> This is executed and creates an ADO recordset that I use in my app.

> When I go to delete a record from the recordset, the delete is deleting
> the record from T1 AND the record from T2. I do not have any relationships
> set between T1 and T2.

> Why is my .delete command deleting the record from T2? TIA, Wayne

 
 
 

ado .delete deletes joined table records?

Post by Wayne Hoove » Wed, 15 Jan 2003 12:56:13


I need help. Badly. I have a SQL query that joins a couple of tables
together
like so:

SELECT T1.Field1, T1.Field2,
               T2.Field1
                FROM T1 LEFT JOIN T1 ON T1.IDField = T2.IDField

This is executed and creates an ADO recordset that I use in my app.

When I go to delete a record from the recordset, the delete is deleting
the record from T1 AND the record from T2. I do not have any relationships
set between T1 and T2.

Why is my .delete command deleting the record from T2? TIA, Wayne

 
 
 

1. instead of delete trigger delete data from table using execute and temporary table for deleted

Hello,

SQL Server 2k has got me confused...below the instead of trigger that
causes all my problems...below the trigger the explanation of my
problem

===============================================================================
create trigger [triggerConcurrenten] on [dbo].[concurrenten]
instead of delete
as
begin
        -- ***** Declare local vars




        begin transaction

        -- ***** Initialize



        select deleted.* into #deleted from deleted

        /*
        Delete data from concurrenten table using the below sql
statement
        works perfectly.
        =============
        delete
        from concurrenten
        where exists(
        select * from #deleted d
        where concurrenten.[id] = d.[id])
        */

        /* Delete using the execute function fails! */







        begin
                raiserror('[triggerConcurrenten]: Error occured!', 16, 1)
                rollback transaction
        end

        commit transaction      
end

===============================================================================

In the trigger I've tried a 'direct' sql statement to delete data from
the concurrenten table. No problem at all...but when I use the execute
function the exact same delete statement fails...what am I doing
wrong?

Thanx in advance for the answer!

Best regards,

Peter

2. Varchars and fragmenting

3. ADO JOIN query, then update or delete records?

4. Copying tables and their structures

5. Deleted records when text file is linked as table (#deleted)

6. When is a 'Dimension' a Dimension?

7. HELP with Deleting Records in Joined Tables

8. PRESS: Informix in the News

9. deleting records from joined tables

10. Error 3167 Record Deleted when there is no deleted record

11. Cannot add record to Visual Foxpro table after deleting all records in table

12. Delete with Join -v- Delete with Subquery

13. INSTEAD OF DELETE and JOIN DELETED