Cascade deletes in SQL Server Compact Edition

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
LeftClick
Posts: 1
Joined: Thu 04 Oct 2007 15:45
Location: South Africa

Cascade deletes in SQL Server Compact Edition

Post by LeftClick » Thu 04 Oct 2007 16:36

Hello

I am using SDAC Standard 4.30 in Delphi 7 Pro to work with a SQL Server Compact Edition 3.1 or 3.5 beta 2 database.

I am trying to implement cascading deletes as described in the Compact Edition Help but get the following error when I call delete on a table: "OLE DB error occured. Code 40EDCh" which according to the OLE error table means "Updating this row caused more than one row to be updated in the data source".

That is exactly what a cascade should be doing! I cannot find any documentation anywhere saying that cascade deletes are not allowed in Compact Edition. I can run the same delete command in SQL Server Management Studio Express on the same compact database and it cascade deletes just fine.

I create the tables using a MSScript like so:

CREATE TABLE Measurements (
Measurement_ID int IDENTITY (1, 1) NOT NULL PRIMARY KEY ,
DateTime datetime NOT NULL ,
State tinyint NOT NULL ,
SerialNumber int NOT NULL ,
MachineLine nvarchar (10) ,
ResultSet_ID nvarchar (40) NULL ,
NumResults int NOT NULL ,
OrderNumber nvarchar (15) NULL
);

CREATE TABLE Results (
Result_ID int IDENTITY (1, 1) NOT NULL PRIMARY KEY ,
Measurement_ID int NOT NULL ,
Actual float NOT NULL ,
Deviation float NOT NULL ,
Oot nvarchar (10) NOT NULL ,
Feature_ID int NOT NULL ,
);

ALTER TABLE Results ADD
CONSTRAINT FK_Results_Measurements FOREIGN KEY
(Measurement_ID) REFERENCES Measurements
(Measurement_ID) ON DELETE CASCADE;

When I call "Delete * From Measurements Where Measurement_ID = 'someid' " with a MSSQL I get the error.

Is there something I am missing or how can I do this?

Best Regards
Kevin

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 08 Oct 2007 14:14

Thank you for information. We have reproduced the problem. The investigation of the problem is in progress. As soon as we solve the problem, or we need more information, we will let you know.

Post Reply