I was playing around with the new bits and wanted to try to use WCF Service using DbSchedulerProviderBase.
I kept getting errors on the DbSchedulerProviderBase method LoadResources when it tries to add a Resource to the appointment.
I thought I must had done something wrong so I open the Quick Start Examples in Visual Studio and altered the example http://demos.telerik.com/aspnet-ajax/scheduler/examples/wcf/defaultcs.aspx to use the MyDbSchedulerProvider instead by passing in the name of provider from web.config:
I then ran the page and got the same error on the method below on line 16:
The method GetResource returns null.
Can you check it out and let us know how to implement client binding from a database.
BTW I added a check for null and it works but of course there is no resources so it is specifically relating to how to load resources.
We can load resources from XML so I guess we just need to change the implementation of DbSchedulerProviderBase unless I have really missed somthing here.
Regards
Axe
I kept getting errors on the DbSchedulerProviderBase method LoadResources when it tries to add a Resource to the appointment.
I thought I must had done something wrong so I open the Quick Start Examples in Visual Studio and altered the example http://demos.telerik.com/aspnet-ajax/scheduler/examples/wcf/defaultcs.aspx to use the MyDbSchedulerProvider instead by passing in the name of provider from web.config:
private WebServiceAppointmentController Controller | |
{ | |
get | |
{ | |
if (_controller == null) | |
{ | |
//_controller = | |
// new WebServiceAppointmentController( | |
// new XmlSchedulerProvider(HttpContext.Current.Server.MapPath("~/App_Data/Appointments_Outlook.xml"), | |
// false)); | |
_controller = new WebServiceAppointmentController("ReadOnlySchedulerData"); | |
} | |
return _controller; | |
} | |
} | |
I then ran the page and got the same error on the method below on line 16:
private void LoadResources(Appointment apt) | |
{ | |
using (DbConnection conn = OpenConnection()) | |
{ | |
DbCommand cmd = DbFactory.CreateCommand(); | |
cmd.Connection = conn; | |
cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID)); | |
cmd.CommandText = "SELECT [TeacherID] FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID AND [TeacherID] IS NOT NULL"; | |
using (DbDataReader reader = cmd.ExecuteReader()) | |
{ | |
if (reader.Read()) | |
{ | |
Resource teacher = apt.Owner.Resources.GetResource("Teacher", reader["TeacherID"]); | |
apt.Resources.Add(teacher); | |
} | |
} | |
cmd.Parameters.Clear(); | |
cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID)); | |
cmd.CommandText = "SELECT [StudentID] FROM [DbProvider_ClassStudents] WHERE [ClassID] = @ClassID"; | |
using (DbDataReader reader = cmd.ExecuteReader()) | |
{ | |
while (reader.Read()) | |
{ | |
Resource student = apt.Owner.Resources.GetResource("Student", reader["StudentID"]); | |
apt.Resources.Add(student); | |
} | |
} | |
} | |
} | |
The method GetResource returns null.
Can you check it out and let us know how to implement client binding from a database.
BTW I added a check for null and it works but of course there is no resources so it is specifically relating to how to load resources.
We can load resources from XML so I guess we just need to change the implementation of DbSchedulerProviderBase unless I have really missed somthing here.
Regards
Axe