OpenAccessDataSource: Solving "Please specify the id and version fields" error

10 posts, 0 answers
  1. Jeff
    Jeff avatar
    51 posts
    Member since:
    Aug 2007

    Posted 13 May 2009 Link to this post

    Hello,

    This error comes up from time to time when I'm using the OpenAccessDataSource with RadGrid and I'd like some tips on troubleshooting it (beyond the obvious).

    I can read data and add new records. However, updating or deleting a record results in the following error:
    Changes are not possible if the primary key fields are not visible. 
    Please specify the id and version fields in the persistent attribute. 
    [Telerik.OpenAccess.Persistent(IdentityFied="id"VersionField="version"]  
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.  
     
    Exception Details: Telerik.OpenAccess.Exceptions.UnsupportedException: Changes are not possible if the primary key fields are not visible. 
    Please specify the id and version fields in the persistent attribute. 
    [Telerik.OpenAccess.Persistent(IdentityFied="id"VersionField="version"
     
    Source Error:  
     
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.   
     
    Stack Trace:  
     
     
    [UnsupportedException: Changes are not possible if the primary key fields are not visible. 
    Please specify the id and version fields in the persistent attribute. 
    [Telerik.OpenAccess.Persistent(IdentityFied="id"VersionField="version"]] 
       Telerik.OpenAccess.RT.DataSource.OpenAccessDataSourceView.CreateObjectId(IDictionary keys, String& oldVersion) +230 
       Telerik.OpenAccess.RT.DataSource.OpenAccessDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +75 
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92 
       Telerik.Web.UI.GridTableView.PerformUpdate(GridEditableItem editedItem, Boolean suppressRebind) +223 
       Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +975 
       Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +134 
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 
       Telerik.Web.UI.GridEditFormItem.OnBubbleEvent(Object source, EventArgs e) +299 
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118 
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135 
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 
     
      
     
     
    -------------------------------------------------------------------------------- 
    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082  



    Here's the class where the error is occurring:
        [Telerik.OpenAccess.Persistent(IdentityField = "m_ID", VersionField = "m_Version")] 
        public class Address 
        { 
            private int m_Version; 
     
            public int Version 
            { 
                get { return m_Version; } 
                set { m_Version = value; } 
            } 
             
            private Guid m_ID; 
     
            public Guid ID 
            { 
                get { return m_ID; } 
                set { m_ID = value; } 
            } 
     
            private string m_strAddress1 = ""
     
            public string Address1 
            { 
                get { return m_strAddress1; } 
                set { m_strAddress1 = value; } 
            } 
     
            private string m_strCity; 
     
            public string City 
            { 
                get { return m_strCity; } 
                set { m_strCity = value; } 
            } 
     
            private string m_strState; 
     
            public string State 
            { 
                get { return m_strState; } 
                set { m_strState = value; } 
            } 
     
    ... more fields and properties... 
     
        } 
     

    I've spent a ridiculous amount of time trying to solve this problem. Other classes in my project are identical in terms of the ID and version but work fine.

    Please tell me what else I can look at or provide you to get to the bottom of this issue.

    Thanks,
    Jeff
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 16 May 2009 Link to this post

    Hello Jeff,

    Our team is still investigating your problem as we have not met with this behavior before. As a temporary workaround I would suggest you not to use your defined field as a version field but, use internal version field instead.

    We will notify you as soon as we have a definite solution for the problem.

    Regards,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Jeff
    Jeff avatar
    51 posts
    Member since:
    Aug 2007

    Posted 17 May 2009 Link to this post

    Hi Zoran,

    Thanks for looking into this.

    I'm not interested in maintaining a version field. I'm just trying to do what the error message is telling me.
     
    I removed the Version= attribute from Persistent line. It now reads: [Telerik.OpenAccess.Persistent(IdentityField = "m_ID")]

    In the Forward Mapping dialog under Concurrency Control, the "Verify By" dropdown says version. The "Field" dropdown is blank.

    I still get the same error.

     If you you'd like me to look at anything- files, Forward Mapping dialog, my ObjectScopeProvider class- let me know. I just want to get the OpenAccessDataSource working for deleting and updating.

    Thanks,
    Jeff
  5. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 20 May 2009 Link to this post

    Hello Jeff,

    The real problem appeared to be that the grid was not passing the id value to the datasource and the reason for that is that you do not have specified "DataKeyNames" property in the design time of the grid.

    There you should specify the identity field/fields of the persistent object you are about to present - in your case that is the "ID" field.

    Testing your case helped us to fix another bug in the OpenAccessDataSource though and this fix will be available in the internal build that you should be able to find on our web site as soon as tomorrow. I suggest you install that version of OpenAccess and just write DataKeyNames="ID" in the RadGrid tag and everything should work as expected.

    Best wishes,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Jeff
    Jeff avatar
    51 posts
    Member since:
    Aug 2007

    Posted 20 May 2009 Link to this post

    Hi  Zoran,

    Sounds good. I'll try it out once the new build is available.

    I hope that Telerik will put the DataKeyNames tidbit in the documentation so that others don't have to go through what I did.

    Thanks,
    Jeff
  7. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 21 May 2009 Link to this post

    Hello Jeff,

    The new build is already on our site. You can download it and try if the functionality is there. We will address your scenario in the appropriate way.

    Best wishes,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Jeff
    Jeff avatar
    51 posts
    Member since:
    Aug 2007

    Posted 21 May 2009 Link to this post

    Hi Zoran,

    I don't see the internal build at this link. Is there somewhere else I should be looking?

    Jeff
  9. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 22 May 2009 Link to this post

    Hi Jeff,
    I verified today, and there are internal builds for OpenAccess Developer and Trial edition. We are not uploading Express edition internal builds.

    Greetings,
    Dimitar Kapitanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Jeff
    Jeff avatar
    51 posts
    Member since:
    Aug 2007

    Posted 01 Jun 2009 Link to this post

    Hi Zoran,

    I'm still getting this error on the internal build. I have a project that demonstrates the problem that I can send you.

    You had converted my related thread to a support ticket ("Cannot insert explicit value..."). However, I'm unable to reply to it and attach my sample project.

    When I started from scratch in a new project, I can add new records to the database from RadGrid. But I'm still getting the "Please specify ID" error when deleting and updating records. The sample project will demonstrate this.

    Please let me know how I can send this project to you.

    Thanks,
    Jeff
  11. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 02 Jun 2009 Link to this post

    Hello Jeff,

    We changed the type of your thead to product feedback now. You should be able to send your project now.

    Greetings,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner