rhill52
asked on
How do I read my SQL dataset and update the Dotnetbar Schedule control ?
Hi I can read in an xml file and update Devcomponents schedule control with below code., but how can I do the same with my SQL Dataset as it does not seem to work.
XML code
Try
If File.Exists(Application.St artupPath & "\Appointments.xml") Then
Dim xml As New Xml.Reader(Application.Sta rtupPath & "\Appointments.xml")
For Each node As Xml.Node In xml.Root.Nodes
Dim appointment As New Appointment()
appointment.OwnerKey = node.Attributes("owner").V alue
appointment.StartTime = node.Attributes("start").V alueDateTi me
appointment.EndTime = node.Attributes("end").Val ueDateTime
appointment.Tag = node.Attributes("preremind ").ValueIn t
appointment.Subject = node.Attributes("subject") .Value
appointment.Description = node.Attributes("descripti on").Value
appointment.Tooltip = appointment.Description
appointment.CategoryColor = node.Attributes("color").V alue
appointment.TimeMarkedAs = node.Attributes("timemarke r").Value
Me.CalendarView1.CalendarM odel.Appoi ntments.Ad d(appointm ent)
Next
SQL CODE THAT IS NOT WORKING.
Private Sub ButtonItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem2.Click
'Me.ScheduleTableAdapter.F ill(Me.Ins pections_S chedule_Da taSet.Sche dule)
Me.ScheduleTableAdapter.Fi ll(Inspect ions_Sched ule_DataSe t.Schedule )
For Each dr As DataRow In Inspections_Schedule_DataS et.Schedul e.Rows
Dim appointment As New Appointment()
appointment.StartTime = dr("starttime")
appointment.EndTime = dr("endtime")
appointment.OwnerKey = dr("owner")
appointment.Tag = dr("tag")
appointment.Subject = dr("subject")
appointment.Description = dr("description")
appointment.CategoryColor = dr("categorycolor")
appointment.Tooltip = appointment.Description
Me.CalendarView1.CalendarM odel.Appoi ntments.Ad d(appointm ent)
Next
MessageBox.Show("data import finished!")
End Sub
The control is availible for trial download from here http://www.devcomponents.com/dotnetbar/download.aspx
XML code
Try
If File.Exists(Application.St
Dim xml As New Xml.Reader(Application.Sta
For Each node As Xml.Node In xml.Root.Nodes
Dim appointment As New Appointment()
appointment.OwnerKey = node.Attributes("owner").V
appointment.StartTime = node.Attributes("start").V
appointment.EndTime = node.Attributes("end").Val
appointment.Tag = node.Attributes("preremind
appointment.Subject = node.Attributes("subject")
appointment.Description = node.Attributes("descripti
appointment.Tooltip = appointment.Description
appointment.CategoryColor = node.Attributes("color").V
appointment.TimeMarkedAs = node.Attributes("timemarke
Me.CalendarView1.CalendarM
Next
SQL CODE THAT IS NOT WORKING.
Private Sub ButtonItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem2.Click
'Me.ScheduleTableAdapter.F
Me.ScheduleTableAdapter.Fi
For Each dr As DataRow In Inspections_Schedule_DataS
Dim appointment As New Appointment()
appointment.StartTime = dr("starttime")
appointment.EndTime = dr("endtime")
appointment.OwnerKey = dr("owner")
appointment.Tag = dr("tag")
appointment.Subject = dr("subject")
appointment.Description = dr("description")
appointment.CategoryColor = dr("categorycolor")
appointment.Tooltip = appointment.Description
Me.CalendarView1.CalendarM
Next
MessageBox.Show("data import finished!")
End Sub
The control is availible for trial download from here http://www.devcomponents.com/dotnetbar/download.aspx
ASKER
Hi Code Cruiser, looking at the data in the xml file created it does not seem to matter if the timemarker value is there or not. am I looping through the rows correctly ?
Yes loop seems fine. Step through the code to see whether its executing or not (The dataset may be empty!).
ASKER
all seems fine when steping through the code, the dataset is loaded and the results change as expected, I suspect it is this line that is causing the issue but I am not sure why.
Me.CalendarView1.CalendarM odel.Appoi ntments.Ad d(appointm ent)
Me.CalendarView1.CalendarM
Enclose it in try catch block and see if you get any errors.
ASKER
still do not see any problems, think it might be best to try the sample and see if you can reproduce ?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Found the issue myself
appointment.TimeMarkedAs = node.Attributes("timemarke