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
2094
ExtendedAppointmentInfo to/from Database
posted

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

    'Add Appointment to CalendarInfo
    Dim apptAsClone As ICloneable = DirectCast(Me.appointment, ICloneable)
    Me.calendarInfo.Appointments.Add(DirectCast(apptAsClone.Clone(), Appointment))

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.

 

 

Parents Reply Children
No Data