Adding multiple records

3 posts, 0 answers
  1. Sean
    Sean  avatar
    54 posts
    Member since:
    Apr 2008

    Posted 14 Jun 2010 Link to this post

    Hi guys,

    I have searched for a solution to this but have not yet seen anything that works.

    I have a static table of tasks that must be completed for a newly submitted request ticket.
    When the user submits his request, I grab the list, assosicte it with the request id and
    populate a task completion table. However, i am getting cache errors from my object scope.

    Here is the code block:

    public void CreateTaskList(int requestid)  
                    //Load the tasks from the static TASKS table  
                    var tasks = Load();  
                    //Create a blank TASK COMPLETION record for each task and associate it with 
                    //the request id 
     this will be updated as various reviewers complete their 
                    //review of the request
                    foreach (var task in tasks)  
                        var asset = new RmoTaskCompletion  
                           RequestId = requestid,  
                           TaskId = task.TaskId,  
                           Date1 = DateTime.Now,  
                           Comments = "",  
                           Submitter = "",  
                           IsComplete = false,  
                           TaskDescription = task.TaskDescription  
                        _sc.Add(asset);//Error is thrown here for the second record  
                catch (Exception ex)  

    Thanks. I imagine it is fairly simple, but I can't seem to solve it.

  2. Serge
    Serge avatar
    375 posts

    Posted 16 Jun 2010 Link to this post

    Hello Sean ,

     I do not see anything wrong with your code so the exception should be coming from the surroundings, this being the object scope provider or the Load() method. 

    Can you please provide information as to what kind of exception is thrown, how are you managing your scope's life cycle or any other thing about your code you think might help figure this out. It would be best if you could provide a demo project but it is not absolutely necessary. 

    I am looking forward to resolving this issue.

    Sincerely yours,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Sean
    Sean  avatar
    54 posts
    Member since:
    Apr 2008

    Posted 17 Jun 2010 Link to this post

    Hi guys,

    I solved my own issue. The table needed to have a key pair. When I first set it up, only RequestId was a key. Now, the RequestId and TaskId form a key pair. I manually added the change to the table as well as the OpenAccess app.config. However, it seems I had to use the tool to regenerate the class for it to work...

    Anyway, the error was being thrown because I was trying to insert a record with a duplicate key (RequestId never changes for this loop, only the taskId). I never saw the duplicate key message, however, so it took me a while to realize my mistake.



Back to Top