Search code examples
.netdb2tableadapter

Pound Sign in column name causes .Net tableadapter to throw error: "Can not parse..."


Attempting to order a SQL select statement that executes properly until the ORDER BY clause is included.

Executing the statement, including the ORDER BY, against the Db2 database via the IBM client access tools works as it should.

The .Net table adapter is able to process the query and pull the data from the remote system without the ORDER BY clause.

Searched extensively for what I thought would be an easy find... go figyah.

Things I've already tried: [], "", \#.

Select <several normally named columns, properly separated by commas>
From <collection>.<table> <correlation_name>
Where <several filter conditions>
Order By column#

EX:

SELECT col1, col2, col3
FROM tableA a
    JOIN tableB b on a.ColJoin = b.ColJoin
WHERE col1 = 1
    AND col2 = 10
ORDER BY colx#

Again, this runs fine in the native environment and produces the proper result set.

I've run out of search terms to use. Any assistance appreciated.


Solution

  • Try using quotes on the whole column:

    Select <several normally named columns, properly separated by commas>
    From <collection>.<table> <correlation_name>
    Where <several filter conditions>
    Order By "column#"
    

    I also found this tidbit for DB2:

    In contrast to regular identifiers, delimited identifiers in IBM DB2 are case sensitive.

    So make sure the case for this column matches the original.