I have created a small "ExtendedAppointmentInfo" class to store some additional appoinment info.
<Serializable()> _Public Class ExtendedAppointmentInfo Private _PhoneNumber As String = Nothing
Public Property PhoneNumber() As String Get Return Me._PhoneNumber End Get Set(ByVal value As String) Me._PhoneNumber = value End Set End Property
End Class
I have my CalendarInfo bound to a Dataset (manually created in code at the moment - will eventually move it to a database). The AllPropertiesDataMember is a DataColumn called "AllProperties" and it has a data type of Byte()
Private Sub SaveAppointments(ByVal Appt as Appointment)
Dim info As ExtendedAppointmentInfo = Nothing info = TryCast(Me.appointment.Tag, ExtendedAppointmentInfo) info.PhoneNumber = "12345678" Appt.Tag = Info
End Sub
This All Works and Appointments.TAG property DOES appear to contain my "ExtendedAppointmentInfo" class. But I am having major problems trying to retrieve the data back.
For Instance. my data table was Declared "WITHEVENTS"
Private Sub AppointmentsTable_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles AppointmentsTable.RowChanged If e.Action = DataRowAction.Add Then If Not IsNothing(e.Row("AllProperties")) And e.Row("AllProperties") IsNot System.DBNull.Value Then Dim Appt As Appointment = Appointment.FromBytes(e.Row("AllProperties")) Dim ExtendedInfo As ExtendedAppointmentInfo = DirectCast(Appt.Tag, ExtendedAppointmentInfo) MessageBox.Show(ExtendedInfo.PhoneHome) End If End If End Sub
The Problem is that When I try to retrieve the AllProperties column value it ALWAYS = System.DbNull.Value
Please help. I need to be able to cast the "All Properties" column back into an appointment object, then cast the appointment.tag back into an ExtendedAppointmentInfo Class.
I should probably mention my ultimate goal which is:
I am having trouble getting the AllProperties Column to populate correctly... everytime i convert the Appointment using
Dim Appt as Appointment = Appointment.FromBytes(_dataRoww("AllProperties"))
When I try to access the .TAG info using:
Dim MyClassInstance as MyClass = DirectCast(Appt.Tag,MyClass)
It is ALWAYS Null :(
At which point/which event should I capture the information in the Appt.Tag custom class and write it directly to my database? AfterAppointmentAdded? DataTable_RowChanged?
I hope i have made a little more sense