Problem with DataSource

6 posts, 0 answers
  1. Sophie
    Sophie avatar
    8 posts
    Member since:
    Nov 2008

    Posted 25 Nov 2008 Link to this post

    I used your class MyAppointment in your trial example...

    This is my code : 

    String query;

    query ="Select * from myTable";
    SqlConnection myConn = new SqlConnection("Data Source=MyServer;Initial Catalog=MyCatalog;User Id=MyUser;Password=MyPassword;");
    SqlCommand cmd = new SqlCommand(query, myConn);
    SqlDataReader read; 
    read = cmd.ExecuteReader();
    while (read.Read())
    MyAppointment app = new MyAppointment(Convert.ToDateTime(read.GetString(2)), Convert.ToDateTime(read.GetString(3)), Convert.ToString(read.GetInt32(0)), read.GetString(1), read.GetString(4));


    SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource(); 
    AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
    appointmentMappingInfo.Start =
    appointmentMappingInfo.End =
    appointmentMappingInfo.Summary =
    appointmentMappingInfo.Description =
    appointmentMappingInfo.Location =
    appointmentMappingInfo.UniqueId =
    SchedulerMapping idMapping = appointmentMappingInfo.FindByDataSourceProperty("Id");  
    dataSource.EventProvider.Mapping = appointmentMappingInfo;
    dataSource.EventProvider.DataSource = appointments;

    .ux_cedule.DataSource = dataSource;

    But I have error message : impossible to convert object 'System.GUID to 'Telerik.WinControls.UI.EventId' type. Do you understand wath is my problem?

    Thanks a lot again

  2. Jordan
    Jordan avatar
    547 posts

    Posted 26 Nov 2008 Link to this post

    Hello Sophie,

    In the same example, please note how convert callbacks are assigned for the id mapping:
    SchedulerMapping idMapping = appointmentMappingInfo.FindByDataSourceProperty("Id"); 
                idMapping.ConvertToDataSource = new ConvertCallback(this.ConvertIdToDataSource); 
                idMapping.ConvertToScheduler = new ConvertCallback(this.ConvertIdToScheduler); 

     private object ConvertIdToScheduler(object id) 
                return new EventId(id); 
            private object ConvertIdToDataSource(object id) 
                return (id != null) ? (id as EventId).KeyValue : Guid.NewGuid(); 

    These callbacks solve that problem.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Derek
    Derek avatar
    104 posts
    Member since:
    Aug 2008

    Posted 10 Dec 2008 Link to this post

    Hi I get the following error with your example:

    Error 1 Delegate 'Telerik.WinControls.UI.ConvertCallback' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor. C:\development\CRM\CRM\Classes\SchedulerEvents.vb 67 61 CRM

    I put 'addressof' in, but now how to i convert the following to VB ? 

    return (id != null) ? (id as EventId).KeyValue : Guid.NewGuid(); 


  4. Jordan
    Jordan avatar
    547 posts

    Posted 12 Dec 2008 Link to this post

    Hello Derek,

    The same example has a VB version. Here is some code from it:
    Private Sub btnBind_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBind.Click 
                      Dim dataSource As New SchedulerBindingDataSource() 
                      Dim appointmentMappingInfo As New AppointmentMappingInfo() 
                      appointmentMappingInfo.Start = "Start" 
                      appointmentMappingInfo.End = "End" 
                      appointmentMappingInfo.Summary = "Subject" 
                      appointmentMappingInfo.Description = "Description" 
                      appointmentMappingInfo.Location = "Location" 
                      appointmentMappingInfo.UniqueId = "Id" 
                      Dim idMapping As SchedulerMapping = appointmentMappingInfo.FindByDataSourceProperty("Id"
                idMapping.ConvertToDataSource = New ConvertCallback(AddressOf Me.ConvertIdToDataSource) 
                idMapping.ConvertToScheduler = New ConvertCallback(AddressOf Me.ConvertIdToScheduler) 
                      dataSource.EventProvider.Mapping = appointmentMappingInfo 
                      dataSource.EventProvider.DataSource = appointments 
                      Me.radScheduler1.DataSource = dataSource 
                End Sub 
                Private Function ConvertIdToScheduler(ByVal id As Object) As Object 
                      Return New EventId(id) 
                End Function 
                Private Function ConvertIdToDataSource(ByVal id As Object) As Object 
                If (Not id Is Nothing) Then 
                    Return (TryCast(id, EventId)).KeyValue 
                    Return Guid.NewGuid() 
                End If 
                End Function 

    You can also use our code converter at to change between C# and VB and vice versa.

    Hope this helps.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Diego
    Diego avatar
    17 posts
    Member since:
    Feb 2010

    Posted 01 May 2010 Link to this post

    Hi I have this similar error.
    Unable to cast object of type 'System.Guid' to type 'System.IConvertible'.Couldn't store <80dcdba4-c699-41c5-b39b-53072a01554d> in ID Column.  Expected type is Int32.

    Database is Access DB(With ID fields as Integer Autonumeric Increment)

    I'm Binding from/to Dataset (The error appears when i try create a new appointment), the error is in dataset level I guess, because i never  call the commit method.

    How to avoid that  the id arrive as GUID in ConvertIdToDataSource(object id) method..

    When I loading appoinments for first time. in ConvertIdToScheduler(object id) the values arrive as iinteger(the same values in database), but I guess that creating a new value create a guid and that will trigger that error)

  6. Dobry Zranchev
    Dobry Zranchev avatar
    353 posts

    Posted 03 May 2010 Link to this post

    Hello Diego,

    Before getting to your question, we would like to remind you to ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here:

    As to your question, please verify the differences between your dataset and the example dataset.

    There are a few problems that we are aware of with working with Access: when you create your dataset from an access database the Id of the appointment is not read only, and also AutoincrementSeed and AutoincrementStep have values -1, but the value should be 1.

    If you have additional questions feel free to ask.

    All the best,
    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.
Back to Top