This is a migrated thread and some comments may be shown as answers.

[Solved] SQLDatasource Insertcommand error

2 Answers 132 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 02 Jun 2008, 06:32 PM

I am getting an Ajax error when I use the following code when I add an appoint. the error is as follows:
-----------------------------------------------------------------------------------------------
Sys.Webforms.pagerequestmanagerServerErrorException:Item has already been added. Key in dictionary:;'ID' key being added: 'ID'.
--------------------------------------------------------------------------------------------------
I am getting similar errors when I delete or update. There is no codebehind code, I am just uing SQLDatasource. I checked that the Appointments table has ID field which is an identity field.
Please let me know.
----------------------------------------------------Code----------------------------------------------------------

<
asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>"

SelectCommand="SELECT * FROM [Appointments]" ProviderName="System.Data.SqlClient"

InsertCommand ="INSERT INTO [Appointments] ([Subject], [Start], [End], [RoomID], [UserID], [RecurrenceRule], [RecurrenceParentID]) VALUES (@Subject, @Start, @End , @RoomID, @UserID, @RecurrenceRule, @RecurrenceParentID)"

UpdateCommand="UPDATE [Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [UserID] = @UserID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE (ID = @ID)"

DeleteCommand="DELETE FROM [Appointments] WHERE [ID] = @ID"

>

<DeleteParameters>

<asp:Parameter Name="ID" Type="Int32" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="ID" Type="Int32" />

<asp:Parameter Name="Subject" Type="String" />

<asp:Parameter Name="Start" Type="DateTime" />

<asp:Parameter Name="End" Type="DateTime" />

<asp:Parameter Name="RoomID" Type="Int32" />

<asp:Parameter Name="UserID" Type="Int32" />

<asp:Parameter Name="RecurrenceRule" Type="String" />

<asp:Parameter Name="RecurrenceParentID" Type="Int32" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="Subject" Type="String" />

<asp:Parameter Name="Start" Type="DateTime" />

<asp:Parameter Name="End" Type="DateTime" />

<asp:Parameter Name="RoomID" Type="Int32" />

<asp:Parameter Name="UserID" Type="Int32" />

<asp:Parameter Name="RecurrenceRule" Type="String" />

<asp:Parameter Name="RecurrenceParentID" Type="Int32" />

</InsertParameters>

</asp:SqlDataSource>

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Jun 2008, 05:10 AM
Hello Sunil,

Can you isolate the problem in a small project and send it to us to examine it?


Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason
Top achievements
Rank 2
answered on 31 Aug 2009, 04:05 AM
I had the same problem and here is what worked for me.  By default when I used the wizard for the radscheduler all fields had my "ID" column listed.  I only changed the fields for start time, finish time and subject while leaving the other two recurring fields with the "ID" as the default.  When I went back and deleted those fields "DataRecurrenceField="id" DataRecurrenceParentKeyField="id" " from the code it worked.
Tags
Scheduler
Asked by
Sunil
Top achievements
Rank 1
Answers by
Peter
Telerik team
Jason
Top achievements
Rank 2
Share this question
or