I am using the following stored procedure to generate a client-sided Batch Optimistic ADO Recordset:CREATE PROCEDURE eml_ListEmailAttachment @AcctID int = NULL, @FolderID int = NULLASSELECT a.AttachmentID, a.EmailID, a.DisplayName, a.PathNameFROM [EmailAttachment] aINNER JOIN Email e ON a.EmailID = e.EmailIDWHERE (@AcctID IS NULL OR e.AcctID = @AcctID) AND (@FolderID Is Null OR e.FolderID = @FolderID)
As you can see, the only fields being selected are from the EmailAttachment table. However, when I delete some records on the client and then call UpdateBatch, ADO sends the following SQL to the server and fails with a message saying "Row could not be located for updating...blah, blah, blah.":exec sp_executesql N'DELETE FROM "WSPC".."Email" WHERE "EmailID"=@P1; DELETE FROM "WSPC".."Email" WHERE "EmailID"=@P2', N'@P1 int,@P2 int', 119, 119exec sp_executesql N'DELETE FROM "WSPC".."EmailAttachment" WHERE "AttachmentID"=@P1; DELETE FROM "WSPC".."EmailAttachment" WHERE "AttachmentID"=@P2', N'@P1 int,@P2 int', 34, 35
It is trying to delete from the Email table once for each EmailAttachment record that I deleted. So, I saved the recordset to a file using the XML persistence format to see the schema, and I see this near the bottom:<s:AttributeType name='c4' rs:name='EmailID' rs:number='5' rs:basecatalog='WSPC' rs:basetable='Email' rs:basecolumn='EmailID' rs:keycolumn='true' rs:hidden='true' rs:autoincrement='true'> <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true' rs:maybenull='false'/></s:AttributeType>
Does anyone know how to avoid this? I could re-write the query using an IN() statement to get the same rows, but in my experience an Inner Join works faster (please tell me if this is false).Thanks!