Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Odd behaviour inserting into Sql CE

Odd behaviour inserting into Sql CE

Scheduled Pinned Locked Moved Mobile
databasehelpquestionc++sql-server
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    freshthinking
    wrote on last edited by
    #1

    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.

    J 1 Reply Last reply
    0
    • F freshthinking

      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.

      J Offline
      J Offline
      Joao Paulo Figueira
      wrote on last edited by
      #2

      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

      F 1 Reply Last reply
      0
      • J Joao Paulo Figueira

        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

        F Offline
        F Offline
        freshthinking
        wrote on last edited by
        #3

        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.

        F 1 Reply Last reply
        0
        • F freshthinking

          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.

          F Offline
          F Offline
          freshthinking
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups