Retrieving "appointments" programmatically with SQL

14 posts, 0 answers
  1. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 27 Jan 2010 Link to this post

    I'm trying to bind the RadScheduler through SQL command programmatically, but I can't display the record found in my database.

    Below is the code I came up with. Kindly point out the flaw.

            Dim mySqlCmd As New SqlCommand 
            Dim da As New SqlDataAdapter 
     
     
            Dim SchedSource As New SchedulerBindingDataSource() 
            Dim appointmentMappingInfo As New AppointmentMappingInfo() 
            Dim resourceMappingInfo As New ResourceMappingInfo 
            Dim mySqlConn = New SqlConnection("server = compname\SQLEXPRESS;database = dbname;Trusted_Connection = yes"
             
            mySqlConn.Open() 
            Try 
                mySqlCmd = mySqlConn.CreateCommand 
                mySqlCmd.CommandText = _ 
                "SELECT tbl_ReservationInfo.ReservationInfoID as 'ID', tbl_ReservationInfo.ReservationStart as 'Start', tbl_ReservationInfo.ReservationEnd as 'End', tbl_ResourceInfo.ResourceName As 'Resource Name', tbl_ResourceInfo.Description as 'Description', tbl_ResourceInfo.Type as 'Type'" 
                mySqlCmd.CommandText += " FROM tbl_ReservationInfo INNER JOIN tbl_Reservations ON tbl_ReservationInfo.ReservationID = tbl_Reservations.ReservationID INNER JOIN tbl_ResourceInfo ON tbl_ReservationInfo.ResourceInfoID = tbl_ResourceInfo.ResourceInfoID INNER JOIN" 
                mySqlCmd.CommandText += " tbl_Resources ON tbl_ResourceInfo.ResourceInfoID = tbl_Resources.ResourceInfoID INNER JOIN" 
                mySqlCmd.CommandText += " tbl_Users ON tbl_ReservationInfo.UserID = tbl_Users.UserID" 
                mySqlCmd.CommandText += " WHERE (tbl_ResourceInfo.Type = 'Venue')" 
                da.SelectCommand = mySqlCmd 
     
                da.Fill(SchedDataSet, "Schedules"
     
                appointmentMappingInfo.Start = "Start" 
                appointmentMappingInfo.End = "End" 
                appointmentMappingInfo.Summary = "Resource Name" 
                appointmentMappingInfo.Location = "Resource Name" 
                appointmentMappingInfo.Description = "Description" 
                appointmentMappingInfo.Visible = "Visible" 
     
                resourceMappingInfo.Id = "ID" 
                resourceMappingInfo.Name = "Type" 
     
     
                SchedulerBindingDataSource1.ResourceProvider.Mapping = appointmentMappingInfo 
                SchedulerBindingDataSource1.ResourceProvider.DataSource = "Schedules" 
     
                SchedulerBindingDataSource1.ResourceProvider.Mapping = resourceMappingInfo 
                SchedulerBindingDataSource1.ResourceProvider.DataSource = "Schedules" 
     
                VenueSchedTable.DataSource = SchedulerBindingDataSource1 
            Catch ex As Exception 
                MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!"
            End Try




    I have one record in my database,wherein if that SQL Select Statement is executed will retrieve it, as seen on the image below:
    http://img69.imageshack.us/img69/4580/12849791.jpg


  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 27 Jan 2010 Link to this post

    Hi mrdcpwns,

    Thank you for the question:

    SchedulerBindingDataSource1.ResourceProvider.Mapping = appointmentMappingInfo
    SchedulerBindingDataSource1.ResourceProvider.DataSource = "Schedules"
       
    SchedulerBindingDataSource1.ResourceProvider.Mapping = resourceMappingInfo
    SchedulerBindingDataSource1.ResourceProvider.DataSource = "Schedules"

    The first two rows in the code above should be set to the EventProvider, not to the  ResourceProvider. Also you should set not names of tables but DataTable objects:

    SchedulerBindingDataSource1.EventProvider.Mapping = appointmentMappingInfo
    SchedulerBindingDataSource1.EventProvider.DataSource = SchedDataSet.Schedules

    If you have no Resources table, you can skip setting the ResourceProvider.

    Sincerely yours,
    Dobry
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 27 Jan 2010 Link to this post

    Ah, I finally made it work!

    Thanks for mentioning Datatable. Instead of Filling a Dataset, I used a datatable. Voila!
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 28 Jan 2010 Link to this post

    Hello mrdcpwns,

    I am happy that everything is working on your side.

    All the best,
    Dobry
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 06 Feb 2010 Link to this post

    How can I group the schedules by resources, such as the one shown on the demo, through sql data adapter?

    What's wrong with the code I made below?

            Dim da As New SqlDataAdapter 
            Dim mySqlCmd As New SqlCommand 
            Dim schedDT As New DataTable 
            Dim resourceDT As New DataTable 
            Dim SchedSource As New SchedulerBindingDataSource() 
            Dim appointmentMappingInfo As New AppointmentMappingInfo() 
            Dim resourceMappingInfo As New ResourceMappingInfo 
            Dim mySqlConn = New SqlConnection(SqlString) 
     
            mySqlConn.Open() 
            Try 
     
                mySqlCmd = mySqlConn.CreateCommand 
                mySqlCmd.CommandText = _ 
                "SELECT tbl_ReservationInfo.ReservationStart AS 'Start', tbl_ReservationInfo.ReservationEnd AS 'End', tbl_ResourceInfo.ResourceName AS 'Name', tbl_ResourceInfo.ResourceInfoID AS 'ID'" 
                mySqlCmd.CommandText += " FROM tbl_ReservationInfo INNER JOIN tbl_Reservations ON tbl_ReservationInfo.ReservationID = tbl_Reservations.ReservationID INNER JOIN" 
                mySqlCmd.CommandText += " tbl_Resources ON tbl_ReservationInfo.ResourceID = tbl_Resources.ResourceID INNER JOIN tbl_ResourceInfo ON tbl_Resources.ResourceInfoID = tbl_ResourceInfo.ResourceInfoID INNER JOIN" 
                mySqlCmd.CommandText += " tbl_Users ON tbl_ReservationInfo.UserID = tbl_Users.UserID" 
                mySqlCmd.CommandText += " WHERE (tbl_ResourceInfo.Type = 'Venue')" 
                da.SelectCommand = mySqlCmd 
     
                da.Fill(schedDT) 
                mySqlCmd.Dispose() 
     
                mySqlCmd = mySqlConn.CreateCommand 
                mySqlCmd.CommandText = _ 
                "SELECT     tbl_ResourceInfo.ResourceName, tbl_ResourceInfo.ResourceInfoID, tbl_ResourceInfo.Type" 
                mySqlCmd.CommandText += " FROM tbl_ResourceInfo INNER JOIN" 
                mySqlCmd.CommandText += " tbl_Resources ON tbl_ResourceInfo.ResourceInfoID = tbl_Resources.ResourceInfoID" 
                mySqlCmd.CommandText += " WHERE (tbl_ResourceInfo.Type = 'Venue')" 
                da.SelectCommand = mySqlCmd 
     
                da.Fill(resourceDT) 
     
     
                appointmentMappingInfo.Start = "Start" 
                appointmentMappingInfo.End = "End" 
                appointmentMappingInfo.Location = "Name" 
     
                appointmentMappingInfo.Visible = "Visible" 
                resourceMappingInfo.Id = "ID" 
                resourceMappingInfo.Name = "Name" 
                resourceMappingInfo.Visible = "Visible" 
     
     
                SchedulerBindingDataSource1.EventProvider.Mapping = appointmentMappingInfo 
                SchedulerBindingDataSource1.EventProvider.DataSource = schedDT 
                SchedulerBindingDataSource1.ResourceProvider.Mapping = resourceMappingInfo 
                SchedulerBindingDataSource1.ResourceProvider.DataSource = resourceDT 
     
                VenueSchedTable.DataSource = SchedulerBindingDataSource1 
                VenueSchedTable.GroupType = GroupType.Resource 
               

  7. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 08 Feb 2010 Link to this post

    Hello mrdcpwns,

    Could you please send us your database scripts? We need just tbl_ResourceInfo and tbl_ReservationInfo tables scripts so that we can effectively help. I am looking forward to helping you further with that.

    Kind regards,
    Dobry Zranchev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 08 Feb 2010 Link to this post

    I also included some other table's scripts, as well as the .mdf files


    http://www.megaupload.com/?d=YQ6CTDXT
  9. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 10 Feb 2010 Link to this post

    Hello mrdcpwns,

    We are attaching a sample application. We found out one small problem with the resource id data binding of appointments while making the example. Please excuse us for inconvenient.

    Feel free to ask additional questions.

    Greetings,
    Dobry Zranchev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  10. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 10 Feb 2010 Link to this post

    I'm having a problem with the sample application attached.

    The Form2.vb and Form2.Designer.vb both have errors in having the class of radscheduler not known, as such
    "Type 'Telerik.Wincontrols.UI.Radscheduler' is not defined", eventhough the telerik wincontrols namespace had already been imported.

  11. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 11 Feb 2010 Link to this post

    Hi mrdcpwns,

    We are attaching a new example. If you cannot start it, try to remove the reference for Telerik.WinControls.Scheduler and add it again. You should also change the connection string to your database.

    Kind regards,
    Dobry Zranchev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  12. mrdcpwns
    mrdcpwns avatar
    16 posts
    Member since:
    Dec 2009

    Posted 11 Feb 2010 Link to this post

    I tried doing that before but the RadScheduler itself cannot be found under Telerik.Wincontrols.UI


    Anyway, What changes can be seen during runtime on the attachment file?

     I've tried  to just copy your source code and put it in my project, but it still has the same problem of having no appointments displayed if the GroupType is set to Resource.
  13. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 12 Feb 2010 Link to this post

    Hello mrdcpwns,

    We know that we cannot visualize the appointments in RadScheduler from a data source. We are working on that issue and it will be resolved in the next release. For the moment we could not give you work-around. Please excuse for the inconvenience.

    Best wishes,
    Dobry Zranchev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  14. Greg
    Greg avatar
    1 posts
    Member since:
    Apr 2011

    Posted 27 Feb 2012 Link to this post

    Has this issue been resolved as I need to do the group by resource binding to SQL
  15. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 02 Mar 2012 Link to this post

    Hello Greg,

    Yes, currently there are not any known issue that can prevent you from binding to SQL and group by resource. If you encounter any difficulties in achieving this, you can either refer to our Online documentation or contact us via a support ticket or a forum thread.

    Should you have any further questions, we will be glad to address them.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready