Binding to Database Example

11 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 16 Dec 2011 Link to this post

    Requirements

    RadControls version Q3 2012
    .NET version 4.0
    Visual Studio version 2010
    programming language C#
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    A sample project which demonstrates how to bind the RadScheduleView to a database. For more details please refer to the following documentation:
    http://www.telerik.com/help/wpf/radscheduleview-populating-with-data-binding-to-db-overview.html

    UPDATE: The latest version of ScheduleView Database examples is available in our XAML SDK Repository at the following link:
    https://github.com/telerik/xaml-sdk/tree/master/ScheduleView/Database
  2. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 25 Apr 2012 Link to this post

    Hi,

    thanks great Example, but i get an error in saving an appointment:

    public void EndEdit()
      {
           // if recurrenceRule is removed, delete all SqlExceptionOccurences and exceptions
        if (this.originalRule != null && this.RecurrenceRule == null)
            {
            this.SqlExceptionOccurrences.ToList()
            .ForEach(ex => ScheduleViewRepository.Entities.DeleteObject(ex));
     
            ScheduleViewRepository.Entities.SqlExceptionOccurrences
                .Where(exc => exc.MasterSqlAppointmentId == this.SqlAppointmentId)
            .ToList()
            .ForEach(ex => ScheduleViewRepository.Entities.SqlExceptionOccurrences.DeleteObject(ex));
             }
     
             ScheduleViewRepository.Entities.SaveChanges();
    }

    This causes an error:         ScheduleViewRepository.Entities.SaveChanges();
    InnerExecption: The used version of SQL Server does not support the data type datetime2 '.

    I use SQLServer Express 2005 and what about "SQLite3" ???

    Thanks
    Rene
  3. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 25 Apr 2012 Link to this post

    Hi,

    Problem solved: If you use SQLExpress2005 and SQLExpress2008 you have to edit the "ScheduleViewEntity.edmx":

    Bevor: (2008)
    <Schema Namespace="ScheduleViewModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">

    After: (2005):
    <Schema Namespace="ScheduleViewModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">

    But i would like to have this example for a sqlite3 Database ;-)

    Thanks
    Regards
    ww
  4. John
    John avatar
    2 posts
    Member since:
    Apr 2009

    Posted 14 Mar 2013 Link to this post

    Hi,

    How would you go about to do resource filtering with this project. I've been playing with it and I have not had much success. I'm just trying to get a combobox filter on one particular resource type (I've deleted the other ones). I have also disabled the grouped view. All I am trying to do now is to filter by the "room" resource. I've been looking at the video to do custom resource filtering and I have been trying to apply it to this project but with no success.

    Thanks,
    Roger
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Mar 2013 Link to this post

    Hello Roger,

    I have attached to this post the MainWindow.xaml and the ViewModel from the project with some modifications in order to implement filtering. Please download the attachment and give it a try.
    Note that in some case when creating the GroupFilterFunc, you should use a lambda expression - this is needed because of some optimizations in the framework:

    this.GroupFilter = new Func<object, bool>(c => this.GroupFilterFunc(c));

    Hope this helps.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Hiwa
    Hiwa avatar
    21 posts
    Member since:
    Mar 2013

    Posted 13 Apr 2013 Link to this post

    Hello Yana,

    thanks for the Example,
    i got an Exception [XamlParseException] in loadData() method of 
    ScheduleViewViewModel.cs [it occurred after that the ScheduleViewDBEntities created and returned by ScheduleViewRepository class]
    
    Help Please ,
    
    Thanks in advance
    hiwa
    this is Exception details:

    System.Windows.Markup.XamlParseException occurred
      HResult=-2146233087
      Message='The invocation of the constructor on type 'ScheduleView_DB_WPF.ViewModels.ScheduleViewViewModel' that matches the specified binding constraints threw an exception.' Line number '10' and line position '4'.
      Source=PresentationFramework
      LineNumber=10
      LinePosition=4
      StackTrace:
           at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
           at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
           at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
           at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           at ScheduleView_DB_WPF.MainWindow.InitializeComponent() in c:\Users\hiwa\Downloads\Compressed\5eb0d517-7d9f-4cb5-9305-cf822e41505c_ScheduleView-DB-WPF\ScheduleView_DB_WPF\MainWindow.xaml:line 1
           at ScheduleView_DB_WPF.MainWindow..ctor() in c:\Users\hiwa\Downloads\Compressed\5eb0d517-7d9f-4cb5-9305-cf822e41505c_ScheduleView-DB-WPF\ScheduleView_DB_WPF\MainWindow.xaml.cs:line 13
      InnerException: System.Data.EntityCommandExecutionException
           HResult=-2146232004
           Message=An error occurred while executing the command definition. See the inner exception for details.
           Source=System.Data.Entity
           StackTrace:
                at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
                at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
                at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
                at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
                at Telerik.Windows.Controls.CollectionExtensions.ForEach[T](IEnumerable`1 source, Action`1 action) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Extensions\CollectionExtensions.cs:line 215
                at Telerik.Windows.Controls.CollectionExtensions.AddRange[T](ICollection`1 collection, IEnumerable`1 items) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Extensions\CollectionExtensions.cs:line 24
                at ScheduleView_DB_WPF.ViewModels.ScheduleViewViewModel.LoadData() in c:\Users\hiwa\Downloads\Compressed\5eb0d517-7d9f-4cb5-9305-cf822e41505c_ScheduleView-DB-WPF\ScheduleView_DB_WPF\ViewModels\ScheduleViewViewModel.cs:line 150
                at ScheduleView_DB_WPF.ViewModels.ScheduleViewViewModel..ctor() in c:\Users\hiwa\Downloads\Compressed\5eb0d517-7d9f-4cb5-9305-cf822e41505c_ScheduleView-DB-WPF\ScheduleView_DB_WPF\ViewModels\ScheduleViewViewModel.cs:line 26
           InnerException: System.Data.SqlClient.SqlException
                HResult=-2146232060
                Message=Invalid object name 'dbo.SqlResourceTypes'.
                Source=.Net SqlClient Data Provider
                ErrorCode=-2146232060
                Class=16
                LineNumber=1
                Number=208
                Procedure=""
                Server=.\SQLEXPRESS
                State=1
                StackTrace:
                     at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                     at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
                     at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
                     at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
                     at System.Data.SqlClient.SqlDataReader.get_MetaData()
                     at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
                     at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
                     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
                     at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
                     at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
                     at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
                     at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
                     at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
                InnerException: 

  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 18 Apr 2013 Link to this post

    Hi Hiwa,

    The important part from this exception is the message:
    Invalid object name 'dbo.SqlResourceTypes'.

    Are you using the same database as ours - we have provided the script for creating it in the Scripts folder? If not, you should re-generate the Entity Model, please follow the instructions in our documentation.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Hiwa
    Hiwa avatar
    21 posts
    Member since:
    Mar 2013

    Posted 18 Apr 2013 Link to this post

    hi Yana ,
     i generated  the database manually and i  made a mistake  .
    i used the script for creating the database and my problem solved.
    thanks a lot,

    hiwa
  9. Hiwa
    Hiwa avatar
    21 posts
    Member since:
    Mar 2013

    Posted 27 Apr 2013 Link to this post

    Hi Telerik Team,
    is there a similar project using Open Access ORM ?
  10. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Apr 2013 Link to this post

    Hi Hiwa,

    I am afraid that we do not have such an example at hand.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Hiwa
    Hiwa avatar
    21 posts
    Member since:
    Mar 2013

    Posted 29 Apr 2013 Link to this post

    Hi Yana,
    :(
    OK, Thank You
Back to Top