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

[Solved] Error when updating scheduler

5 Answers 255 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 10 Jul 2008, 11:10 PM
I get this error when I try to update, insert or delete scheduler:

Sys.WebForms.PageRequestManagerServerErrorException:  Item has already been added. Key dictionart: 'ScheduleID' Key being added: 'ScheduleID'

I am using an Access database and nothing in the code behind file.

Any ideas?

Here is my aspx code:

<

telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="End"

DataKeyField="ScheduleID" DataRecurrenceField="ScheduleID"

DataRecurrenceParentKeyField="ScheduleID" DataSourceID="AccessDataSource1"

DataStartField="Start" DataSubjectField="Subject">

</telerik:RadScheduler>

<asp:AccessDataSource ID="AccessDataSource1" runat="server"

DataFile="~/Database/AmbLL.mdb"

DeleteCommand="DELETE FROM [Schedule] WHERE [ScheduleID] = ?"

InsertCommand="INSERT INTO [Schedule] ([ScheduleID], [Subject], [Start], [End]) VALUES (?, ?, ?, ?)"

SelectCommand="SELECT * FROM [Schedule]"

UpdateCommand="UPDATE [Schedule] SET [Subject] = ?, [Start] = ?, [End] = ? WHERE [ScheduleID] = ?">

<DeleteParameters>

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

</DeleteParameters>

<UpdateParameters>

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

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

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

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

</UpdateParameters>

<InsertParameters>

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

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

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

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

</InsertParameters>

</asp:AccessDataSource>

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 11 Jul 2008, 02:26 PM
Hello Stuart,

Thank you for contacting us.

You should set different fields to the DataRecurrenceField and DataRecurrenceParentKeyField properties. In case you don't need recurring appointments, these properties can be unset.

The ScheduleID value is auto increment and can't be set in the insert query.
You can read more information here.
 
Regards,
Yana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Stuart
Top achievements
Rank 1
answered on 12 Jul 2008, 04:55 PM

ok, thanks for the response.

I took of one problem now I have another.

I get the message now:

Sys.WebForms.PageRequestManagerServerErrorException: You tried to assign the Null value to a variable that is not a Variant data type.

I think I know what the problem is but I don't know how to fix it.

I am using an MS Access database and all the examples I have found use SQL Server. Is there an example that uses Access.

Here is my code:

<

telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="End"

DataKeyField="ID" DataRecurrenceField="RecurranceRule"

DataRecurrenceParentKeyField="RecurranceParentID"

DataSourceID="AccessDataSource1" DataStartField="Start"

DataSubjectField="Subject" Skin="Vista">

 

</telerik:RadScheduler>

 

<asp:AccessDataSource ID="AccessDataSource1" runat="server"

DataFile="~/Database/AmbLL.mdb"

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

InsertCommand="INSERT INTO [Appointments] ([ID], [Subject], [Start], [End], [RecurranceRule], [RecurranceParentID], [Annotations]) VALUES (?, ?, ?, ?, ?, ?, ?)"

SelectCommand="SELECT * FROM [Appointments]"

UpdateCommand="UPDATE [Appointments] SET [Subject] = ?, [Start] = ?, [End] = ?, [RecurranceRule] = ?, [RecurranceParentID] = ?, [Annotations] = ? WHERE [ID] = ?">

 

<DeleteParameters>

 

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

 

</DeleteParameters>

 

<UpdateParameters>

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

</UpdateParameters>

 

<InsertParameters>

 

<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="RecurranceRule" Type="String" />

 

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

 

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

 

</InsertParameters>

 

</asp:AccessDataSource>

I think the problem is the the ID is an AutoNumber and in the insert statement I have ID but when I take it out of the insert statement I get another error message that says Number of  query values and destination fields are not the same.

I used the Data Source Configuation Wizard and it build the code in the aspx file.  What am I missing or doing wrong?



0
Stuart
Top achievements
Rank 1
answered on 12 Jul 2008, 05:04 PM
Disregard my last post. I figured it out.  thanks for all your help
0
Ross
Top achievements
Rank 2
answered on 24 Feb 2009, 08:40 PM
OK Stuart, what was the solution that you said that you had? It would be appreciated if you shared what your solution is, in addition to just stating a problem.

I believe that what you found was:

1.) The Insert command that was auto generated included an ID parameter, and
2.) The Insert Parameters collection that was auto generated included the ID Parameter

For your code to run, without throwing errors, you needed to delete the ID parameter from the Insert Statement and from the Insert parameters collection:

New Insert Command:

 

InsertCommand="INSERT INTO [CalendarData] ( [Subject], [StartTime], [EndTime]) VALUES (?, ?, ?)"

 


New list of Insert Parameters:

 

<InsertParameters>

 

 

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

 

 

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

 

 

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

 

 

</InsertParameters>

 


And, now the code works!


0
Gideon
Top achievements
Rank 1
answered on 02 Apr 2009, 04:19 AM
I also had Sys.WebForms.PageRequestManagerServerErrorException.
It happenned to me whenever I saved messages with occurences (clicking 'option' when adding an appointment).

After taking the Ajax controls out, I found out that the message is error in get_Range.

After a whole day research I found the solution and I provide it for others here:
I am using my own dbProvider. When you use your own provider, you do not need the DataXXXField properties in the Schedular definition as the provder manages that. Well, almost true, you need DataRecurrenceField and 

DataRecurrenceParentKeyField

otherwise, you get the above Error. I put dummy values there and it solved my error. It doesn't call my provider in any case.

Tags
Scheduler
Asked by
Stuart
Top achievements
Rank 1
Answers by
Yana
Telerik team
Stuart
Top achievements
Rank 1
Ross
Top achievements
Rank 2
Gideon
Top achievements
Rank 1
Share this question
or