Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my table I have 5 fields,In those fields,Those are

1.questionId
2.questionUserId
3.SurveyId
4.answer
5.answerId

while I was saving records,I am passing "answer" field and "survey" field as a parameter to my action method. My answer parameter is in the form of string separated my semicolumn.I am splitting this one using "semicolumn" and by executing the for loop I am trying to save values into the database.

How I have to save is that,For adding new record,In the for loop all record values are same except "answer" and "answerId" which is auto incrementing. while I am saving,For the first time of execution new record is saving but for next iteration,It is throwing DuplicateKeyUnhandledByUserCode and Instance of 'DataModel.question_answer' with identity '1850137295-2-1-2-11' already exists in the cache of the object scope.
Posted
Updated 7-Nov-12 1:43am
v2
Comments
MT_ 7-Nov-12 8:13am    
What is the primary key of the table?
AshishChaudha 8-Nov-12 0:14am    
Could you please share your code for better help..

1 solution

Create a new Object of The table type in the loop
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900