DataAccess with BindingSource & Windows Forms Problem

4 posts, 0 answers
  1. Bassam
    Bassam avatar
    2 posts
    Member since:
    May 2009

    Posted 12 Aug 2014 Link to this post

    Hello,

    Im evaluating Data Access ORM as a gate to also purchase DevCraft complete package , I want to move away from Entity Framework into a more powerful and clean ORM, I read the features and I like it, installed the free edition but having a problem getting data binding to work properly as I expect in a windows forms test app, here is what I did (im using SQL Server 2012):

    1. Create a class lib project , create the domain model , insert only 1 table
    2. at same solution in the main app exe windows forms app , I referenced the open access 2 dlls , config file , class lib project ,  no problem
    3. in the main app , I created a project new data source , pointed to the domain model then the table object (entity)
    4. in a new form, i dragged a MS DataGridView , then dragged the object entity from the data source window into the GridView , then columns are automatically created and a BindingSource is created in the form tray , no problem so far and this exactly so far like entity framework
    5. in the form load I created a new context , then a LINQ query to read all the data like that
    myContext=new ControlModel
    dim IPList = From a in db.IPLists
    IPListBindingSource.DataSource=IPList

    6. running the app , now I can see the data in the grid and edit it , however I can NOT add new rows, the + sign of the navigator is not active , if I enforce that by
    IPListBindingSource.AllowNew=True
    then the + sign in the navigator is now active and I can add new row to the grid but when I try to save to SQL server later by running
    db.SaveChanges
    nothing is saved to the database

    7. same problem with deleting rows , when I delete a row from the grid then save
    db.SaveChanges
    its not deleted from database

    so I have problem in both Delete & Insert , but SELECT (LINQ) & EDIT then save works fine

    can you kindly tell me what im doing wrong , all this works fine with Entity Framework with exactly same steps

    Thank you
    Bassam
  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 15 Aug 2014 Link to this post

    Hello Bassam,

    Thank you for contacting us.

    To help you in your evaluation process of the integration between Telerik Data Access and Windows Forms, I would suggest to you to take a look at the WinForms Quick - Start section in our documentation and the Basic Data Binding with Windows Forms sample in Telerik Data Access Samples Kit.

    In both of this suggestions you will find one and the same example, which demonstrates all the basic CRUD operations executed with the help of RadGridView from the Telerik UI for WinForms suite. The documentation will give you a step-by-step guide for the reproduction of the sample, while in the code delivered with Samples Kit you can test your own modifications and ideas.

    I hope this helps. If you need further assistance, do not hesitate to get back to us.



    Regards,
    Doroteya
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Bassam
    Bassam avatar
    2 posts
    Member since:
    May 2009

    Posted 21 Aug 2014 in reply to Doroteya Link to this post

    Hello Doroteya ,

    Thank you for your reply , I have read and followed the example you specified , it works but by implementing a background code behind the grid to delete rows or in case of adding new rows it opens a totally new grid to enter one .

    in my test, to delete the row in the background code it was easy, but I don't want to open new form for user to add a new row , I want the new row to be added to the context once user enters it in the main grid, and im wondering why this is not happening automatically like the Entity Framework , As a work around and while validating the row event of the grid I added the row just entered into the context using code , but it needs more work sometimes to manage and would be easier if this is done automatically along with deleting a row, it would be easier

    appreciate your reply, as maybe there is a method and I don't know it.

    Thank you
    Bassam
  5. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 26 Aug 2014 Link to this post

    Hello Bassam,

    Thank you for your feedback.

    A scenario like the one you describe is possible to be implemented with Telerik Data Access, although currently there is no out-of-the-box resource that demonstrates it. However, in this forum post, you can find an example that will guide you how to add new records through the grid and how to display related data. The project attached to this post is implemented for Visual Studio 2012 and the language is VB. In case you prefer using C#, you can use the Telerik Code Converter to help you with the translation.

    I hope this helps. If you need further assistance, do not hesitate to get back to us.


    Regards,
    Doroteya
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top