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

[Solved] Update-error

6 Answers 148 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Björn
Top achievements
Rank 1
Björn asked on 21 Jan 2008, 12:21 PM
Hi!
I get an error message when I try to update an appointment in the RadScheduler which says: " Exception Details: System.Data.SqlClient.SqlException: Måste deklarera den skalära variabeln "@ID". " For some reason it is in Swedish, the translasion would be something like: "You have to declare the scalable varible "@ID". ".

When I try to delete an appointment I get a postback and no error but the meeting is still there. I dont have any problem with the select or insert-statements.
 
I followed the instructions on this page for the databainding: http://www.telerik.com/help/radcontrols/prometheus/schedule_declarative_databinding.html

Does anyone know what the problem might be?

Note: I dont yet have anything in my cs-file.

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Jan 2008, 03:07 PM
Hi Kristian,

We are not sure why this problem occurs. Do you have a small demo projec which we can test locally? You can open a support ticket and attach files there.


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Björn
Top achievements
Rank 1
answered on 21 Jan 2008, 03:13 PM
Hi Peter!
Thx for the reply. I just managed to fix the problem by adding this (in the apsx): OnAppointmentUpdate="RadScheduler1_AppointmentUpdate1"

And this in the cs-file: 

protected

void RadScheduler1_AppointmentUpdate1(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
{
int appointmentID = Convert.ToInt32(e.Appointment.ID);

SqlDataSource1.UpdateCommand =

"UPDATE [tblAppointments] SET [Subject] = @Subject, [Starttime] = @Starttime, [Endtime] = @Endtime, [UserID] = @UserID, [RoomID] = @RoomID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE ([ID] = " + appointmentID + ")";
}

 

0
T. Tsonev
Telerik team
answered on 22 Jan 2008, 08:23 AM
Hello Kristian,

Your workaround will work fine, but I think that the underlying problem should be easy to solve. You are probably missing the ID parameter in the SqlDataSource parameters list. The default definition looks like this:

<sds:SessionDataSource ID="AppointmentsDataSource" runat="server"  
    DisplayWarning="true" 
    PrimaryKeyFields="ID" 
    ProviderName="System.Data.SqlClient" 
    ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>" 
    SelectCommand="SELECT * FROM [Appointments]" 
    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> 
</sds:SessionDataSource>     

Can you confirm that the UpdateParameters section contains the ID parameter?

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Björn
Top achievements
Rank 1
answered on 22 Jan 2008, 02:58 PM
Hi Tsvetomir!
Thanks for you reply, did not work for me though. The diffenrence between your and mine is that I use the asp:SqlDataSource while you seem to use sds:SessionDataSource.

I cant use the sds, do I need a certain reference or do I need to install something (I guess that this is one of your controls)?

Regards
Kristian
0
T. Tsonev
Telerik team
answered on 22 Jan 2008, 04:03 PM
Hello Kristian,

Sorry for the confusion. SessionDataSource is a slightly modified SqlDataSource that we use for our demos. I have copied the markup verbatim without cleaning it up. So, SessionDataSource can be replaced with SqlDataSource and the DisplayWarning and PrimaryKeyFields attributes should be removed:

<asp:SqlDataSource ID="AppointmentsDataSource" runat="server"  
    ProviderName="System.Data.SqlClient"  
    ConnectionString="<%$ ConnectionStrings:RadSchedulerConnectionString %>"  
    SelectCommand="SELECT * FROM [Appointments]"  
    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>   


Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Björn
Top achievements
Rank 1
answered on 23 Jan 2008, 09:04 AM
Thank you Tsvetomir,
this code worked out the problem for me!

Best Regards
Kristian
Tags
Scheduler
Asked by
Björn
Top achievements
Rank 1
Answers by
Peter
Telerik team
Björn
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or