Author Topic: ID not updated after insert, Delete fails due to no ID  (Read 4212 times)

heavykevy

  • Newbie
  • *
  • Posts: 7
    • View Profile
ID not updated after insert, Delete fails due to no ID
« on: July 31, 2014, 05:19:56 pm »
How do I make sure that the inserted records get updated with the new primary key?
I am using MSSQL with an autogenerated Primary Key.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: ID not updated after insert, Delete fails due to no ID
« Reply #1 on: July 31, 2014, 11:32:17 pm »
you have to return the ID of new record from server in single row mode
and
records along with their ID from server in case of batch editing.

Please refer these demos.
http://paramquery.com/pro/demos/editing

http://paramquery.com/pro/demos/editing_batch

heavykevy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: ID not updated after insert, Delete fails due to no ID
« Reply #2 on: August 02, 2014, 11:16:45 pm »
I am using the batch editing, and I can add a record and the server sends the reply back.
I see the 2 following messages:
From the add action
[{"P":"","DistanceID":0,"HashID":5,"DownID":1,"DrillNumber":1,"DrillItemID":879,"DrillID":85,"FieldPositionID":1}]
From the update action
[{"P":"","DistanceID":0,"HashID":5,"DownID":1,"DrillNumber":1,"DrillItemID":0,"DrillID":85,"FieldPositionID":1}]

I only added a record and saved.  Why is the update action fired?
The DrillItemId of 879 is the newly inserted record.
Why did the DrillItemId revert back to 0 and send an update?
does the order of the data returned matter?

heavykevy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: ID not updated after insert, Delete fails due to no ID
« Reply #3 on: August 06, 2014, 04:00:28 pm »
Issue solved finally...
I had two issues:
For the New Record, I was setting the primaryId to 0 when it should have been set to Null.
When returning the JSON response, there was header data being sent also that was interfering with the decoding of the JSON Response.