This is a migrated thread and some comments may be shown as answers.

Retrieving "appointments" programmatically with SQL

13 Answers 232 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
mrdcpwns
Top achievements
Rank 1
mrdcpwns asked on 27 Jan 2010, 07:27 AM
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


13 Answers, 1 is accepted

Sort by
0
Dobry Zranchev
Telerik team
answered on 27 Jan 2010, 01:42 PM
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.
0
mrdcpwns
Top achievements
Rank 1
answered on 27 Jan 2010, 02:35 PM
Ah, I finally made it work!

Thanks for mentioning Datatable. Instead of Filling a Dataset, I used a datatable. Voila!
0
Dobry Zranchev
Telerik team
answered on 28 Jan 2010, 08:31 AM
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.
0
mrdcpwns
Top achievements
Rank 1
answered on 07 Feb 2010, 04:21 AM
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 
           

0
Dobry Zranchev
Telerik team
answered on 08 Feb 2010, 11:12 AM
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.
0
mrdcpwns
Top achievements
Rank 1
answered on 08 Feb 2010, 11:44 PM
I also included some other table's scripts, as well as the .mdf files


http://www.megaupload.com/?d=YQ6CTDXT
0
Dobry Zranchev
Telerik team
answered on 10 Feb 2010, 03:52 PM
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.
0
mrdcpwns
Top achievements
Rank 1
answered on 10 Feb 2010, 05:17 PM
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.

0
Dobry Zranchev
Telerik team
answered on 11 Feb 2010, 08:39 AM
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.
0
mrdcpwns
Top achievements
Rank 1
answered on 11 Feb 2010, 11:07 AM
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.
0
Dobry Zranchev
Telerik team
answered on 12 Feb 2010, 08:40 AM
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.
0
Greg
Top achievements
Rank 1
answered on 28 Feb 2012, 01:29 AM
Has this issue been resolved as I need to do the group by resource binding to SQL
0
Ivan Todorov
Telerik team
answered on 02 Mar 2012, 09:32 AM
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 >>
Tags
Scheduler and Reminder
Asked by
mrdcpwns
Top achievements
Rank 1
Answers by
Dobry Zranchev
Telerik team
mrdcpwns
Top achievements
Rank 1
Greg
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or