• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1506
  • Last Modified:

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.StartupPath & "\Appointments.xml") Then
                Dim xml As New Xml.Reader(Application.StartupPath & "\Appointments.xml")
                For Each node As Xml.Node In xml.Root.Nodes
                    Dim appointment As New Appointment()

                    appointment.OwnerKey = node.Attributes("owner").Value
                    appointment.StartTime = node.Attributes("start").ValueDateTime
                    appointment.EndTime = node.Attributes("end").ValueDateTime
                    appointment.Tag = node.Attributes("preremind").ValueInt
                    appointment.Subject = node.Attributes("subject").Value
                    appointment.Description = node.Attributes("description").Value
                    appointment.Tooltip = appointment.Description
                    appointment.CategoryColor = node.Attributes("color").Value
                    appointment.TimeMarkedAs = node.Attributes("timemarker").Value
                    Me.CalendarView1.CalendarModel.Appointments.Add(appointment)
                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.Fill(Me.Inspections_Schedule_DataSet.Schedule)
        Me.ScheduleTableAdapter.Fill(Inspections_Schedule_DataSet.Schedule)
        For Each dr As DataRow In Inspections_Schedule_DataSet.Schedule.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.CalendarModel.Appointments.Add(appointment)



        Next


        MessageBox.Show("data import finished!")
    End Sub

The control is availible for trial download from here  http://www.devcomponents.com/dotnetbar/download.aspx
 
0
rhill52
Asked:
rhill52
  • 5
  • 3
1 Solution
 
CodeCruiserCommented:
Are all the values same in SQL and XML? You have missed one line in SQL code which may make a difference

appointment.TimeMarkedAs = node.Attributes("timemarker").Value
0
 
rhill52Author Commented:
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 ?
0
 
CodeCruiserCommented:
Yes loop seems fine. Step through the code to see whether its executing or not (The dataset may be empty!).
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
rhill52Author Commented:
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.CalendarModel.Appointments.Add(appointment)

0
 
CodeCruiserCommented:
Enclose it in try catch block and see if you get any errors.
0
 
rhill52Author Commented:
still do not see any problems, think it might be best to try the sample and see if you can reproduce ?
0
 
rhill52Author Commented:
The issue was down to extra spaces when trying to read appointment.OwnerKey = dr("owner")
from the dataset.

0
 
rhill52Author Commented:
Found the issue myself
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now