Odd behaviour inserting into Sql CE
-
I have a relation called Correspondence of the following format: corrId int identity(1, 1) primary key type varchar(50) cwith varchar(50) isInternal smallint(2) rowguid uniqueidentifier the rowguid attribute was added by sql server when setting up merge replication. On the CE application I am trying to insert a row into the table and then pull the corrId back out using @@IDENTITY. Strangely when I try and insert I get the following error: HR: 800040E2F Native: 25016 Message: A duplicate value cannot be inserted into a unique index [,,,,,] Source: Microsoft SQL Server 2000 Windows CE Edition Parameter 1: 0 Parameter 2: 0 Parameter 3: 0 Parameter 4: Parameter 5: Parameter 6: I could understand the error if the corrId wasn't being incremented by 1 each time (& it didn't have the uniqueidentifier attribute). The question is what am I missing that's causing the problem? Thanks in advance.
-
I have a relation called Correspondence of the following format: corrId int identity(1, 1) primary key type varchar(50) cwith varchar(50) isInternal smallint(2) rowguid uniqueidentifier the rowguid attribute was added by sql server when setting up merge replication. On the CE application I am trying to insert a row into the table and then pull the corrId back out using @@IDENTITY. Strangely when I try and insert I get the following error: HR: 800040E2F Native: 25016 Message: A duplicate value cannot be inserted into a unique index [,,,,,] Source: Microsoft SQL Server 2000 Windows CE Edition Parameter 1: 0 Parameter 2: 0 Parameter 3: 0 Parameter 4: Parameter 5: Parameter 6: I could understand the error if the corrId wasn't being incremented by 1 each time (& it didn't have the uniqueidentifier attribute). The question is what am I missing that's causing the problem? Thanks in advance.
Docs say: "Ensure that a replication publication is configured to manage identity columns for a table(s) in the publication." Is your publication correctly configured? By the way, what layer are you using to access the DB: ADO oe OLE DB? Regards, João Paulo
-
Docs say: "Ensure that a replication publication is configured to manage identity columns for a table(s) in the publication." Is your publication correctly configured? By the way, what layer are you using to access the DB: ADO oe OLE DB? Regards, João Paulo
If you mean did i let it use "Mark identity columns with the NOT FOR Replication" thing, i let enterprised manager sort it out. I have no problem inserting into other tables that have identity attributes, which is why i am finding this very odd behaviour. I am using OLE DB. I haven't use Sql CE before and based my code on an example from the MSDN site, which used OLE DB. ACctually in the connection string for the SqlCeConnection object when i stated a 'Provider' initially it gave errors saying invalid token or something along those lines, so i removed it and specified the 'Data Source' only, and it works. I'm not entirely sure what it uses in that case. However def OLE DB for the replication.
-
If you mean did i let it use "Mark identity columns with the NOT FOR Replication" thing, i let enterprised manager sort it out. I have no problem inserting into other tables that have identity attributes, which is why i am finding this very odd behaviour. I am using OLE DB. I haven't use Sql CE before and based my code on an example from the MSDN site, which used OLE DB. ACctually in the connection string for the SqlCeConnection object when i stated a 'Provider' initially it gave errors saying invalid token or something along those lines, so i removed it and specified the 'Data Source' only, and it works. I'm not entirely sure what it uses in that case. However def OLE DB for the replication.
Coudln't work out what was causing it, so I changed the format of the table to remove the identity attreibute, all working now. thanks.