?
Solved

How do I read my SQL dataset and update the Dotnetbar Schedule control ?

Posted on 2010-11-09
8
Medium Priority
?
1,467 Views
Last Modified: 2012-05-10
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
Comment
Question by:rhill52
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34100291
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
 

Author Comment

by:rhill52
ID: 34100385
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34100428
Yes loop seems fine. Step through the code to see whether its executing or not (The dataset may be empty!).
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:rhill52
ID: 34100786
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34100961
Enclose it in try catch block and see if you get any errors.
0
 

Author Comment

by:rhill52
ID: 34101054
still do not see any problems, think it might be best to try the sample and see if you can reproduce ?
0
 

Accepted Solution

by:
rhill52 earned 0 total points
ID: 34145066
The issue was down to extra spaces when trying to read appointment.OwnerKey = dr("owner")
from the dataset.

0
 

Author Closing Comment

by:rhill52
ID: 34182374
Found the issue myself
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question