Invalid column name.

6 posts, 0 answers
  1. Josh
    Josh avatar
    5 posts
    Member since:
    Jul 2011

    Posted 27 Sep 2011 Link to this post

    So I  was put on this project to try and fix some issues. What i'm having a issue with is an invalid column name error being thrown.
    
    Issue first appeared as 'ParameterName2' so just to get through that section of code I added a ParameterName2 column to the table, then the error moved to ParameterName3 and so on down the line.
    
    I cannot find anywhere in the code where it would add a # to the end of the column based on the previous number so I don't know why it is doing this.
    
    Any help would be greatly appreciated.
    
    Below is the stack:
    
    [SQLException: Invalid column name 'ParameterName4'.
    Invalid column name 'ParameterName4'.
    Statement(s) could not be prepared.]
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery() +267
       OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery() +53
       OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute() +62
    
    [DataStoreException: Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'ParameterName4'.
    Invalid column name 'ParameterName4'.
    Statement(s) could not be prepared.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()
    SQL:
    SELECT a.[ParameterName4] AS COL1, b.[ParameterName] AS COL2, b.[Description] AS COL3, b.[Display] AS COL4, b.[HasDisplayValues] AS COL5, b.[HasMarkers] AS COL6 FROM [AssetPositionInfo] a LEFT JOIN [ParameterDefinitions] AS b ON (a.[ParameterName4] = b.[ParameterName]) WHERE a.[AssetPositionInfoId] = ?                        Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'ParameterName4'.
    Invalid column name 'ParameterName4'.
    Statement(s) could not be prepared.
  2. Josh
    Josh avatar
    5 posts
    Member since:
    Jul 2011

    Posted 28 Sep 2011 Link to this post

    Its doing it on this code now too.

    Its like it is adding the 4 to the column name at query creation time.

    SELECT a.[Id4] AS COL1, b.[Id] AS COL2, b.[Description] AS COL3, b.[TenantId] AS COL4 FROM [SignInventory].[Signs] a LEFT JOIN [SignInventory].[SignCodes] AS b ON (a.[Id4] = b.[Id]) WHERE a.[SignId] = ?                        Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Id4
     should be
    SELECT a.[Id] AS COL1, b.[Id] AS COL2, b.[Description] AS COL3, b.[TenantId] AS COL4 FROM [SignInventory].[Signs] a LEFT JOIN [SignInventory].[SignCodes] AS b ON (a.[Id] = b.[Id]) WHERE a.[SignId] = ?                        



    [SQLException: Invalid column name 'Id4'.
    Invalid column name 'Id4'.
    Statement(s) could not be prepared.]
       Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery() +267
       OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery() +53
       OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute() +62
    
    [DataStoreException: Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Id4'.
    Invalid column name 'Id4'.
    Statement(s) could not be prepared.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()
    SQL:
    SELECT a.[Id4] AS COL1, b.[Id] AS COL2, b.[Description] AS COL3, b.[TenantId] AS COL4 FROM [SignInventory].[Signs] a LEFT JOIN [SignInventory].[SignCodes] AS b ON (a.[Id4] = b.[Id]) WHERE a.[SignId] = ?                        Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Id4'.
    Invalid column name 'Id4'.
    Statement(s) could not be prepared.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
       at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()]
       Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e) +4
       Telerik.OpenAccess.RT.ExceptionWrapper.Throw() +14
       OpenAccessRuntime.DataObjects.PCStateMan.handleException(Exception x) +58
       OpenAccessRuntime.DataObjects.PCStateMan.getObjectFieldImp(PersistenceCapable pc, FieldMetaData fmd, Object currentValue) +101
       OpenAccessRuntime.DataObjects.PCStateMan.getObjectField(PersistenceCapable pc, Int32 field, Object currentValue) +37
       EPIC.Works.BusinessObject.Sign.OpenAccessEnhancedGetsignCode(Sign ) +99
       EPIC.Works.BusinessObject.Sign.get_SignCode() in C:\Users\Administrator\Desktop\localhost\EPIC Works BLL\Sign.generated.cs:574
       SignInventoryMap.Page_Load(Object sender, EventArgs e) in e:\WebServices\EPICWorks\SignInventoryMap.aspx.cs:107
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
  3. DevCraft banner
  4. Josh
    Josh avatar
    5 posts
    Member since:
    Jul 2011

    Posted 28 Sep 2011 Link to this post

    Ok looks like it is an issue with the Domain Model.

    When I update from our database it doesn't pull in the foreign keys. So I have to go into the generated source code and add the foreign keys code in and everything seems to work fine.

    Now to figure out how to get it to happen automatically as we are still using the 2010 tools and doesn't look like upgrade is possible soon.

    Hope this may help anyone else if they ever run into this issue.
  5. Kosta Hristov
    Admin
    Kosta Hristov avatar
    13 posts

    Posted 30 Sep 2011 Link to this post

    Hello Josh,

    The "Invalid column" error you receive is caused by the absence of the foreign key columns in your model, as you already figured out. If for some reason there is no column defined in the model association for the foreign key, OpenAccess will try to generate a column during runtime. If the name that will get generated is not the same as the foreign column name in the database, "Invalid column name <guessed_name>" exception will be thrown. Note that the changes you do to your model table will be applied only in your local model and will not be applied on the database table unless you forward map your changes.
    Unfortunately I am not sure which is the exact version of our product you are using and because of this I cannot direct you weather you should run the forward mapping wizard or not (it might not be part of the version you have).,

    If case you are using a version that does not contain the forward mapping wizard, you can manually update the database to match your model. You can see how this can be done in the following documentation article.

    In order to assist you further on this issue, I will need to know the exact version of OpenAccess you are using. Any additional information regarding your setup will also be of help.

    I'm looking forward to resolving this issue with you.

    Regards,
    Kosta Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  6. Josh
    Josh avatar
    5 posts
    Member since:
    Jul 2011

    Posted 30 Sep 2011 Link to this post

    Thank you for your response any help to get it fixed so I do not have to add code by hand to the generated classes will be greatly appreciated. If the version difference is an issue I will just have to live with it for now.

    Here is all the software the company has. I'm still getting started with your products so not sure what one you are looking for.

    RadControls for ASP.NET AJAX

    Your current version: 2010.3 1317 (Jan 17, 2011) Release notes

    Telerik Extensions for ASP.NET MVC

    Your current version: 2010.3 1318 (Jan 18, 2011) Release notes

    RadControls for WinForms

    Your current version: 2010.3 10.1215 (Dec 15, 2010) Release notes

    Telerik Reporting

    Your current version: 2010.3 1221 (Dec 22, 2010) Release notes

    RadControls for WPF

    Your current version: 2010.3 1314 (Jan 14, 2011) Release notes

    RadControls for Windows Phone

    Your current version: 2011.1 Beta2 (Mar 1, 2011) Release notes

    Telerik OpenAccess ORM

    Your current version: 2010.3 1125 (Nov 26, 2010) Release notes

    JustCode

    Your current version: 2010.3 1327 (Jan 27, 2011) Release notes

    RadControls for Silverlight

    Your current version: 2010.3 1314 (Jan 14, 2011) Release notes


     - Josh
  7. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 05 Oct 2011 Link to this post

    Hi Josh,

    Generally, our recommendation is to consider upgrading to the latest release of Telerik OpenAccess ORM - namely Q2 2011. If you do so, you can directly download our latest stable build - Telerik-OpenAccess-ORM-trial-2011.2.908.1.zip.

    We can also try to come up with a workaround for your specific situation. In order to be sure what has gone wrong with the older version model, we would like to take a look at your RLINQ file (the model definition) and the Database Schema it is created from. If you opt to proceed in this direction, let us know - we will change the ticket type so that you will be able to privately attach the required files.

    I am looking forward to your feedback.

    All the best,
    Ivailo
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft banner