locked
CLS compliant problem RRS feed

  • Question

  • HI;

    I inherited a sql server database with several tables. Almost all of these tables have collumn names that are not CLS compliant i.e the names do include a space such as 'customer name'. Print Document and Crystal Reports work fine with such configuration. Lately, I wanted to give a try to the reportviewer, but unfortunately I am receiving an error message that the names are not CLS compliant. Not being able to change all of the names of all the collumns in the database, I am asking if there is a way to correct the situation. Thanks.

    Monday, October 12, 2020 6:58 PM

Answers

  • Two thoughts if you can't use proper column names.

    • Used brackets eg. [customer name]
    • Or [Customer name] As CustomerName
    • Or create a view and use column aliases e.g. same as bullet 2, this way whatever uses the column only sees the aliases.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Proposed as answer by Andrew B. Painter Monday, October 12, 2020 7:47 PM
    • Marked as answer by vblover29 Monday, October 12, 2020 7:50 PM
    Monday, October 12, 2020 7:39 PM

All replies

  • Two thoughts if you can't use proper column names.

    • Used brackets eg. [customer name]
    • Or [Customer name] As CustomerName
    • Or create a view and use column aliases e.g. same as bullet 2, this way whatever uses the column only sees the aliases.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Proposed as answer by Andrew B. Painter Monday, October 12, 2020 7:47 PM
    • Marked as answer by vblover29 Monday, October 12, 2020 7:50 PM
    Monday, October 12, 2020 7:39 PM
  • Two thoughts if you can't use proper column names.

    • Used brackets eg. [customer name]
    • Or [Customer name] As CustomerName
    • Or create a view and use column aliases e.g. same as bullet 2, this way whatever uses the column only sees the aliases.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    In case your SQL Server is MySQL (or its fork MariaDB) and not MS SQL, you can enclose schema/table/column names in backticks.  eg

    SELECT FROM `my db`.`my table` WHERE `my db`.`my table`.`customer name` = 4;


    Before you can learn anything new you have to learn that there's stuff you don't know.



    • Edited by Andrew B. Painter Monday, October 12, 2020 7:51 PM Corrected/clarified what is a schema vs table vs field reference. Hopefully!
    Monday, October 12, 2020 7:50 PM