Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Binding AllProperties and RecurrenceID
posted

I am using UltraWinSchedule (2008.1), and specifically the UltraCalendarInfo component, and I am using the standard AppoinmentDialog and the standard AppointmentRecurrenceDialog to work with appointments.

 

I am binding the AllPropertiesMember of the UltraCalendarInfo to a datasource that is a generic list of a custom class that has a property type of byte(), which in turn gets persisted to a SQL Server table into a column of varbinary(max).

 

Nulls are allowed in the SQL Server column, because appointments may be entered into the table outside of the standard AppointmentDialog  (such as a user simply entering a startdate, enddate, and subject in an UltraWinGrid).

 

I am having two problems with this methodology:

 

The first problem is that when I read the null SQL column into the class, I get an error that ‘Object of type System.DBNull cannot be converted to System.Byte()’.  To get around this, in the SQL datareader method, I set the value to an empty Byte () using System.Text.Encoding.UTF8.GetBytes(String.Empty), when the value read from the database is system.dbnull.  I also tried defaulting the SQL column to ‘0x’ so that it would never be Null.

 

Either workaround prevents the error however, now the appointment will not show on the calendar.  So in other words, I can’t seem to figure out how to read in a ‘Null’ AllProperties column, and have the calendar still use the other bound properties (StartDate, EndDate, and Subject) to place the appointment properly on the calendar.

 

A related error occurs when I try to add an appointment to an Ultrawingrid bound to the same datasource.  When the record is added via the grid, the AllProperties Property will initially be ‘nothing’, and I get an error originating from: UltraWinSchedule.Appoinment.FromBytes, that indicates <Buffer cannot be null. Parameter name: buffer>.  I can work around this error  by setting the private member of the AllProperties Property as in:

Private _allProperties() As Byte = System.Text.Encoding.UTF8.GetBytes(String.Empty)

but this causes the same issue in that the appointment will not show up on the calendar.

 

Assuming  I add a regular (non-recurring) appointment through the calendar, everything works fine because the AllProperties member will be set with a value that is not null when the AppointmentDialog is closed, and will be read back and forth into the database properly.

 

The second problem I have is that in this custom class I also have a Property RecurrenceID of type (System.Guid).  When I try to add a recurrence (hit save and close on the appointment dialog, after creating the recurrence), I get an error message originating from Infragistics.Win.UltraWinSchedule.Appointment.BoundPropertySet that indicates ‘Object of System.DBNull connot be converted to type System.guid’.

 

In the Infragistics WinSchedule sample entitled ‘DataBinding VB.sln’, there is a similar situation with a UltraCalendarInfo and an UltraWinGrid bound to the same datasource (however in this example it is bound to a datatable not a generic list).  In this sample, it appears that you can add an appointment via the grid or the calendar and no errors are generated.

 

As a work round for the first problem, I can probably force users to always enter appointments through the calendar, (the currently existing appointments in the table will have to be deleted and re-added via the Appointment dialog) and that will ensure the AllProperties column cannot be null.  However, that does not solve my second problem with the recurrenceID error.

 

I appreciate if any one might have any comments on this or if anyone has a similar situation., or if you need further clarification of my problem please let me know.

 

Thanks!

Parents Reply Children