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

SqlClr context

2 Answers 59 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jean-Marc
Top achievements
Rank 1
Jean-Marc asked on 09 Jan 2013, 10:12 AM
Hi,
I'm getting this error in a page containing a radscheduler
"The requested operation requires a SqlClr context, which is only available when running in the Sql Server process."

I'm quite sure it comes from the sqlDatasource specified on radscheduler and its ResourceTypes, If I remove those DataSourceID, error does not happen (nothing works of course)


Here is the radscheduler
<telerik:RadScheduler runat="server" ID="RadScheduler1"            
           DataSourceID="SqlDataSource1"
          SelectedView="TimelineView"
          DayEndTime="23:59:59"            
          DataKeyField="ID"
          DataSubjectField="Subject"
          DataStartField="StartDate"
          DataEndField="EndDate"
          DataRecurrenceField="RecurrenceRule"
          DataRecurrenceParentKeyField="RecurrenceParentID"
          DataDescriptionField="Description"
          DataReminderField="Reminder"
          AdvancedForm-EnableCustomAttributeEditing="true"
          CustomAttributeNames="VisibleFrom, VisibleTo, AvailableFrom, AvailableTo, IDTimeLineResource, LastModified"
          OverflowBehavior="Expand"            
          Localization-HeaderMultiDay="Work Week"
          OnNavigationComplete="RadScheduler1_NavigationComplete"           
          EnableDescriptionField="True"
          Culture="it-IT"
          RowHeight="70px"
          AppointmentStyleMode="Default"
          OnClientAppointmentContextMenu="appointmentContextMenu"           
          OnClientAppointmentContextMenuItemClicked="appointmentContextMenuItemClicked"
          OnClientAppointmentContextMenuItemClicking="appointmentContextMenuItemClicking"   
          OnClientTimeSlotContextMenu="OnClientTimeSlotContextMenu"             
          OnTimeSlotContextMenuItemClicking="RadScheduler1_TimeSlotContextMenuItemClicking"
          onclientappointmentmoveend="RadScheduler1_AppointmentMoveEnd"
          onclientappointmentmovestart="RadScheduler1_AppointmentMoveStart"                 
          >
           
           
          <AdvancedForm EnableCustomAttributeEditing="True" />
          <TimelineView HeaderDateFormat="dddd, d MMMM yyyy" />
          <TimelineView ColumnHeaderDateFormat="ddd d/M" />
 
          <AdvancedForm Modal="true" />
 
 
 
          <AppointmentTemplate>               
               <div class="rsAptSubject" style="height:20px">
                   <%# Eval("Subject") %>
               </div>                
               <div style="vertical-align:top;height:20px;background-color:Gray" >
               Vis: <%# FormatDateTime(Eval("VisibleFrom"))%> - <%# FormatDateTime(Convert.ToDateTime(Eval("VisibleTo")).AddDays(-1))%>
               </div>
               <div style="vertical-align:top;height:20px;background-color:Orange" >
               Disp: <%# FormatDateTime(Eval("AvailableFrom"))%> - <%# FormatDateTime(Convert.ToDateTime(Eval("AvailableTo")).AddDays(-1))%>
               </div>
           </AppointmentTemplate>
 
 
           <AdvancedEditTemplate>
               <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit"
                   Subject='<%# Bind("Subject") %>'
                   Description='<%# Bind("Description") %>'
                   Start='<%# Bind("Start") %>'
                   End='<%# Bind("End") %>'
                   RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'                                                                              
                   CategoriaID='<%# Bind("IDTimeLineResource") %>'         
                   VisibleFrom='<%# Bind("VisibleFrom") %>'
                   VisibleTo='<%# Bind("VisibleTo") %>'
                   AvailableFrom='<%# Bind("AvailableFrom") %>'
                   AvailableTo='<%# Bind("AvailableTo") %>'                    
                   />
           </AdvancedEditTemplate>
 
           
           <AdvancedInsertTemplate>
               <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert"
                   Subject='<%# Bind("Subject") %>'
                   Start='<%# Bind("Start") %>'
                   End='<%# Bind("End") %>'
                   Description='<%# Bind("Description") %>'
                   RecurrenceRuleText='<%# Bind("RecurrenceRule") %>'
                   CategoriaID='<%# Bind("IDTimeLineResource") %>'    
                   VisibleFrom='<%# Bind("VisibleFrom") %>'
                   VisibleTo='<%# Bind("VisibleTo") %>'
                   AvailableFrom='<%# Bind("AvailableFrom") %>'
                   AvailableTo='<%# Bind("AvailableTo") %>'              
                   />
           </AdvancedInsertTemplate>
           
           
          <ResourceTypes>
              <telerik:ResourceType   KeyField="IDTimeLineResource"
                                      DataSourceID="SqlDataSource2"
                                      ForeignKeyField="IDTimeLineResource"
                                      Name="Categoria"
                                      TextField="ResourceName"                                                                                
                                      AllowMultipleValues="False" />              
          </ResourceTypes>
 
 
 
          <Localization HeaderMultiDay="Work Week" />
           
          <TimelineView GroupBy="Categoria"
                          GroupingDirection="Vertical" 
                          UserSelectable="False"/>
           
          <MultiDayView UserSelectable="false" />
           
          <DayView UserSelectable="false" />
          <WeekView UserSelectable="false" />
          <MonthView UserSelectable="false" />
          <Reminders Enabled="false" />
 
 
      <%--<AppointmentTemplate>
          <div class="rsCustomAppointmentContainer <%# Eval("IDTimeLineResource") %>">
              <h2>
                  <%# Eval("Subject") %>
              </h2>
              <div>
              </div>
          </div>
      </AppointmentTemplate>--%>
 
    
          <AppointmentContextMenus>
           <%--The appointment context menu interaction is handled on the client in this example--%>
           <%--See the JavaScript code above--%>
              <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">
                  <Items>
                      <telerik:RadMenuItem Text="Apri" Value="CommandEdit" />
                      <telerik:RadMenuItem IsSeparator="True" />
                      <telerik:RadMenuItem Text="Categorizza">
                          <Items>
                              <%--
                              <telerik:RadMenuItem Text="Development" Value="1" />
                              <telerik:RadMenuItem Text="Marketing" Value="2" />
                              <telerik:RadMenuItem Text="Personal" Value="3" />
                              <telerik:RadMenuItem Text="Work" Value="4" />
                              --%>
                          </Items>
                      </telerik:RadMenuItem>
                      <telerik:RadMenuItem IsSeparator="True" />
                      <telerik:RadMenuItem Text="Elimina" Value="CommandDelete" />
                  </Items>
              </telerik:RadSchedulerContextMenu>
          </AppointmentContextMenus>
 
          <TimeSlotContextMenus>
              <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerTimeSlotContextMenu">
                  <Items>
                      <telerik:RadMenuItem Text="Nuovo" Value="CommandAddAppointment" />
                      <telerik:RadMenuItem Text="Nuovo (ricorrente)"  Value="CommandAddRecurringAppointment" />
                      <telerik:RadMenuItem IsSeparator="true" />
                      <%-- Custom command --%>
                      <telerik:RadMenuItem Text="Oggi" Value="CommandGoToToday" />
                      <telerik:RadMenuItem IsSeparator="true" />
                      <telerik:RadMenuItem Text="Avanti 1 mese" Value="CustomCommandPlus1Month" />
                      <telerik:RadMenuItem Text="Indietro 1 mese" Value="CustomCommandMeno1Month" />
                      <telerik:RadMenuItem IsSeparator="true" />
                      <telerik:RadMenuItem Text="Vedi Settimana" Value="CustomCommandWeekView" />
                      <telerik:RadMenuItem Text="Vedi 15gg" Value="CustomCommand15ggView" />
                      <telerik:RadMenuItem Text="Vedi Mese" Value="CustomCommandMonthView" />
                       
                  </Items>
              </telerik:RadSchedulerContextMenu>
          </TimeSlotContextMenus>
 
 
 
      </telerik:RadScheduler>

here is datasources
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="Data Source=DEV;Initial Catalog=GM2;Persist Security Info=True;User ID=sa;Password=***;Connect Timeout=120;Context Connection='true'"
        SelectCommand="SELECT [IDTimeLineResource], [ResourceName], [ResourceDescription] FROM [SCH_RESOURCES_0]">
    </asp:SqlDataSource>
 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="Data Source=DEV;Initial Catalog=GM2;Persist Security Info=True;User ID=sa;Password=***;Connect Timeout=120;Context Connection='true'"
        SelectCommand="SELECT [ID], [StartDate], [EndDate], [Subject], [Description], [Reminder], [RecurrenceRule], [RecurrenceParentID], [IDTimeLineResource], [VisibleFrom], [VisibleTo], [AvailableFrom], [AvailableTo], [LastModified] FROM [SCH_Appointements_0]" >
    </asp:SqlDataSource>
(password is correct, I just hide it here)

I attached a screen shot of the 2 db-table involved.

Last thing, this worked fine until some days ago. I don't know why it does not now. 

Thank you





2 Answers, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 14 Jan 2013, 08:55 AM
Hello,

We are not aware of such issue with our RadScheduler control. Please find a sample project attached that demonstrates our suggested approach for using SQL data source for retrieving RadScheduler appointments and resources as well. I have researched the provided error and I concluded that the issue you are facing is regarding the SQL connection by itself.I would like to recommend you to review following online help articles that explains some restrictions and tips of using the "context connection":

I am also attaching a sample web page where is implemented the correct way you bind RadScheduler with resources to SQL.

Hope this will be helpful.

Kind regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jean-Marc
Top achievements
Rank 1
answered on 18 Jan 2013, 09:35 AM
Honestly I have not understood how Context Connection works and what case apply to my scenario.
Anyway removing Context Connection='true' from the connection string solved it.

so, from
ConnectionString
="Data Source=DEV;Initial Catalog=GM2;Persist Security Info=True;User ID=sa;Password=***;Connect Timeout=120;Context Connection='true'"
to
ConnectionString="Data Source=DEV;Initial Catalog=GM2;Persist Security Info=True;User ID=sa;Password=***;Connect Timeout=120"

Thank you Boyan 
Tags
Scheduler
Asked by
Jean-Marc
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Jean-Marc
Top achievements
Rank 1
Share this question
or