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

Scheduler Data Mapping

5 Answers 220 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Al asked on 13 Apr 2012, 06:19 PM
I have created a RadScheduler / RadSchedulerNavigator on a form.   On the Form_Load Event I create a DataTable from a SQL database, add the DataTable to a DataSet and then map the values to my database.

Dim AppointmentDT As DataTable = SQLRowToDt(connStr, "Select * From AppointmentTable")

        ' Appointment Dataset
        Dim AppointmentDataSet As DataSet = New DataSet()
        Dim AppointmentDTCopy As DataTable = AppointmentDT.Copy
        AppointmentDTCopy.TableName = "AppointmentDT"
        AppointmentDataSet.Tables.Add(AppointmentDTCopy)

        ' Appointment Mappings
        Dim appointmentMappingInfo As New AppointmentMappingInfo()
        appointmentMappingInfo.Start = "StartTime"
        appointmentMappingInfo.End = "EndTime"
        appointmentMappingInfo.Summary = "Subject"
        appointmentMappingInfo.Description = "Description"
        appointmentMappingInfo.Location = "Location"
        appointmentMappingInfo.BackgroundId = "Background"
        appointmentMappingInfo.StatusId = "StatusID"
        appointmentMappingInfo.RecurrenceRule = "RecurrenceRule"
        SchedulerBindingDataSource1.EventProvider.Mapping = appointmentMappingInfo
        SchedulerBindingDataSource1.EventProvider.DataSource = AppointmentDataSet.Tables("AppointmentDT")
        RadScheduler1.DataSource = SchedulerBindingDataSource1 

I can add / edit / delete / save back to the database the series just fine.  However if I attempt to edit or delete a single occurrence I get a NullReferenceException.

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Telerik.WinControls.Scheduler"
  StackTrace:
       at Telerik.WinControls.UI.Scheduler.BindingProviderBase`1.FindDataSourceProperty(SchedulerMapping mapping)
       at Telerik.WinControls.UI.SchedulerBindingDataSource.EventBindingProvider.GetExceptionList(Object dataItem)
       at Telerik.WinControls.UI.SchedulerBindingDataSource.EventBindingProvider.InsertCore(IEvent itemToInsert)
       at Telerik.WinControls.UI.Scheduler.BindingProviderBase`1.Insert(T itemToInsert)
       at Telerik.WinControls.UI.RadScheduler.OnAddAppointments(IList list)
       at Telerik.WinControls.UI.RadScheduler.appointments_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.ObservableCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.UI.SchedulerAppointmentCollection.OnExceptionsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.ObservableCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
       at Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item, Action`1 approvedAction)
       at Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.WinControls.UI.SchedulerAppointmentCollection.InsertItem(Int32 index, IEvent item)
       at System.Collections.ObjectModel.Collection`1.Add(T item)
       at Telerik.WinControls.UI.SchedulerUIHelper.DeleteAppointment(IEvent appointment, RadScheduler scheduler)
       at Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog.OnDeleteButtonClicked()
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at Telerik.WinControls.RadControl.OnClick(EventArgs e)
       at Telerik.WinControls.UI.RadButtonBase.buttonElement_Click(Object sender, EventArgs e)
       at Telerik.WinControls.RadItem.OnClick(EventArgs e)
       at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
       at Telerik.WinControls.RadItem.DoClick(EventArgs e)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog.Telerik.WinControls.UI.Scheduler.Dialogs.IEditAppointmentDialog.ShowDialog()
       at Telerik.WinControls.UI.RadScheduler.ShowAppointmentEditDialog(IEvent appointment, Boolean recurringAppointment)
       at Telerik.WinControls.UI.RadScheduler.editAppointment_Click(Object sender, EventArgs e)
       at Telerik.WinControls.RadItem.OnClick(EventArgs e)
       at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
       at Telerik.WinControls.RadItem.DoClick(EventArgs e)
       at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at MartzSchedule.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

This is my first time using RadScheduler, any help you can give me would be greatly appreciated.

Thanks

5 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 18 Apr 2012, 02:46 PM
Hi Allen,

Thank you for contacting us.

As far as I see from your code snippet, you have not set the MasterEventId property of your AppointmentMappingInfo instance. The MasterEventId should contain the name of the column that contains the ID of the original recurring appointment. This field is needed because the exceptions from a recurrence pattern are stored as separate records.

Please try adding such field and map it to the SchedulerBindingDataSource and let me know if this helps. Also, if you have any additional questions, feel free to ask.

All the best,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Al
Top achievements
Rank 1
answered on 19 Apr 2012, 04:18 PM
I have seemed to resolved my initial issue with the NullReferenceException.  I added lines for the
appointmentMappingInfo.Exceptions
 and
appointmentMappingInfo.MasterEventId

However, I am not sure what I should set these properties to.  As I said before the NullReferenceException has been fixed anytime that I attempt to delete or modify a single occurrence, but now if I try to save back to the database, the database doesn't get updated.

I have been looking around for examples on what I should set the above properties to.  In the demo it shows,
	appointmentMappingInfo.Exceptions = "Exceptions" 
appointmentMappingInfo.MasterEventId = "MasterAppointment" But doesn't go into detail where these values should be set. I have found a blog,  http://blogs.telerik.com/winformsteam/posts/09-11-04/radscheduler-for-winforms-data-binding-and-occurrence-exceptions.aspx 
that has 
	appointmentMappingInfo.Exceptions = "AppointmentsAppointments";
	appointmentMappingInfo.MasterEventId = "ParentID";
which suggests that the Exceptions property should be pointing to a DataRelation, but doesn't go into details about what it is relating.

Any help or examples you could give me would be greatly appreciated.

Thanks!
0
Ivan Todorov
Telerik team
answered on 21 Apr 2012, 02:56 PM
Hello Allen,

The Exceptions property of the AppointmentMappingInfo should be set with the name of the relation that connects the ID field with the ParentID field in the Appointments table (please refer to the attachment).

The ParentID column should contain the ID of the original recurring appointment. As I mentioned in my previous post, exceptions are stored as separate records and they hold a reference to the original recurring appointment by using this field. Therefore, the MasterEventId property of the AppointmentMappingInfo should be set with the name of the column that holds the ID of the original appointment (i.e. ParentID).

I hope this will help you. Please let me know if you are still experiencing difficulties.

Regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Al
Top achievements
Rank 1
answered on 23 Apr 2012, 04:35 PM
In my database I have set my ID and ParentID type to uniqueidentifier

I have created a relation relating the ID and ParentID in the Appointments table.  Set the Exceptions property to the relation and set the MasterEventId property to the ParentID.

appointmentMappingInfo.Exceptions = "AppointmentsExceptions"
        appointmentMappingInfo.MasterEventId = "ParentID"


Now when I attempt to save my Appointment back to the database I get,

System.Data.SqlClient.SqlException: Incorrect syntax near 'c2'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at DatabaseLib.DatabaseLib.InsertDataRow(String conStr, String TableNm, DataRow DRow, Boolean UseFldTypes)


When trying to insert the following into the table.

INSERT INTO 
AppointmentTable 
([Subject], [Background], [StartTime], [EndTime], [Description], [RecurrenceRule], [UniqueID], [ParentID], [MasterEventID]) 
Values 
('Hours',
 '1',
  '4/22/2012 8:00:00 AM',
  '4/22/2012 5:00:00 PM',
  'Project',
  'FREQ=DAILY;UNTIL=20120428T000000Z',
  19612ec2-7f14-4a70-a03d-71d3be45eaae,
  null,
  null)



Please help me understand what I am doing wrong.

Thanks.
0
Ivan Todorov
Telerik team
answered on 24 Apr 2012, 03:01 PM
Hello Allen,

The reason for this error is that in RadScheduler's appointments, the UniqueId property is of the GUID type. The error in your statement comes when you try to insert the UniqueId of the appointment to the UniqueID field of your database. As I am not sure what is the type of your UniqueID field in your database and also how you have generated your queries, I would suggest to remove the UniqueID mapping from your AppointmentMappingInfo instance. This would not have any effect on the functionality unless you really need to store and use the UniqueID of the appointments.

If you are still experiencing issues, you can open a new support ticket and attach a sample project which demonstrates your approach. A database script or backup would also be necessary. Being able to run your project locally will let me investigate it and let you know which are the exact steps you need to take in order to correct it.

I hope this helps. Feel free to contact us whenever you need further assistance.

All the best,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Scheduler and Reminder
Asked by
Al
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Al
Top achievements
Rank 1
Share this question
or