Always Getting Error executing query: Telerik.OpenAccess.RT.sql.SQLException

Thread is closed for posting
5 posts, 0 answers
  1. Aniket Braganza
    Aniket Braganza avatar
    14 posts
    Member since:
    May 2008

    Posted 23 Feb 2009 Link to this post

    Can someone please help me? I have been trying to get Telerik support to help me with this for over 24 hours now with no response. I am very disappointed with the support of OpenAccess. All the other products are so well supported and responses are so quick!

    I have a Data project for my entity classes and a web project for my site. I followed the Telerik best practices example to set this up. My issue is that no matter what I do I can't seem to get OpenAccess's scope code to connect and brin back data. I get the following exception everytime, even for the simplest linq expression.

    When I hover over the var that I have declared fr the OQL it says "Telerik.OpenAccessQuery #2 not executed" and then if I let it continue I get the error mentioned below.

    BackendQuery = '(query).BackendQuery' threw an exception of type 'Telerik.OpenAccess.RT.QueryBuilderImp.QueryBuildingException'

    base {System.Exception} = {"Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'user_name'.\r\nInvalid column name 'user_id'.\r\nInvalid column name 'application_id'.\r\nInvalid column name 'is_anonymous'.\r\nInvalid column name 'last_activity_date'.\...

    BackendError = {"Invalid column name 'user_name'.\r\nInvalid column name 'user_id'.\r\nInvalid column name 'application_id'.\r\nInvalid column name 'is_anonymous'.\r\nInvalid column name 'last_activity_date'.\r\nInvalid column name 'lowered_user_name'.\r\nInvalid column n...

    I get a similar error message no matter what table I try.

    Something as simple as this query in my aspx page does not work.
    string Parentlastname = "EVANS"
            var query = from o in cachedScope.Extent<Family>() 
                        where o.Parentlastname.Equals(Parentlastname) 
                        select o; 

    My aspx page code used to looked like this:
    using System;  
    using System.Web.Security;  
    using Telerik.OpenAccess;  
    using Tutoring.Data;  
    using System.Web;  
      
    public partial class login : System.Web.UI.Page  
    {  
        private IObjectScope cachedScope;  
      
        protected void Page_Init(object sender, EventArgs e)  
        {  
            cachedScope = ((login_MasterPage)Master).Scope;  
        }  
      
        protected void Page_Load(object sender, EventArgs e)  
        {  
        }  
      
        protected void Login1_LoggedIn(object sender, EventArgs e)  
        {  
      
            cachedScope.Transaction.Begin();  
            Tutoring.Data.DBUser currentUser = Tutoring.Data.BLL.DBUserManager.GetItemByName(Login1.UserName, cachedScope);  
           
            if (currentUser != null)  
            {  
                SessionHandler.Userid = currentUser.UserId;  
      
                SessionHandler.Applicationid = currentUser.ApplicationId;  
      
                SessionHandler.Siteid = currentUser.Sites[0].Siteid;  
      
                if (currentUser.Teachers.Count > 0)  
                {  
                    SessionHandler.Teacherid = currentUser.Teachers[0].Teacherid;  
                    SessionHandler.Tutoring = currentUser.Teachers[0].Tutoring.Value;  
                }  
                else  
                {  
                    SessionHandler.Teacherid = Guid.Empty;  
                    SessionHandler.Tutoring = true;  
                }  
            }  
            cachedScope.Transaction.Commit();  
      
            HttpCookie cookie = new HttpCookie("Tutoring");  
            cookie.Expires = DateTime.Now + new TimeSpan(1, 0, 0);  
            cookie.Values.Add("userid", SessionHandler.Userid.ToString());  
            cookie.Values.Add("siteid", SessionHandler.Siteid.ToString());  
            cookie.Values.Add("applicationid", SessionHandler.Applicationid.ToString());  
            cookie.Values.Add("teacherid", SessionHandler.Teacherid.ToString());  
            cookie.Values.Add("tutoringacct", SessionHandler.Tutoring.ToString());  
            Response.Cookies.Add(cookie);  
      
            FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true);  
      
        }  
    }  


    Please can someone help me with this!!

    Thanks in advance.

    Aniket
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Feb 2009 Link to this post

    Hello Aniket,

    that looks like as if either you don't open the database you intended to open or you did not update the database so that some columns are missing (assuming you did not reverse-engineer the database).
    Your query and the code snippet look fine, so I'm sure it must be some configuration issue. Please
    verify that from your web.config no second definition of the same connection identifier exists, check also the embedded app.config of your class library.

    Sincerely yours,
    Thomas
    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. Aniket Braganza
    Aniket Braganza avatar
    14 posts
    Member since:
    May 2008

    Posted 24 Feb 2009 Link to this post

    the database was reverse engineered to create the classes. I enabled openaccess in my web project and did all my work in my data access project. There is a connection definition in each config the appconfig for the library and the webconfig for the website, but there is only one objectscope provider and that is in my data access project. As I said I followed what had been done in your best practices example.

    Thanks

    Aniket
  4. Aniket Braganza
    Aniket Braganza avatar
    14 posts
    Member since:
    May 2008

    Posted 25 Feb 2009 Link to this post

    Does anyone know why this could be happening? I simply can't get it to bring back my data, but the reverse engineering connects using the same data with no problem.
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 26 Feb 2009 Link to this post

    Hi Aniket,

    could you please verify that the configuration is correct for both the reverse engineering wizard and your application? We recently had the same issue here where the database was not the one we thought it was, and not finding the columns could be a valid symptom of that. Please check your connection identifier used by your application (normally "DatabaseConnection1"). Also, you can use the Configuration->Connection Settings menu to test the connection (the rev. engineering might read from the reversemapping.config file).

    Best wishes,
    Thomas
    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