Hi all,

I'm trying to bring up a table of data using a select query to create a DataSet that I'm displaying in a datagrid. When I use

SELECT * FROM myTable

it works fine, but when I only want the specific columns

SELECT URN, 'CanX Reason', 'Date to take effect?' FROM myTable

it doesn't.

The URNs are displaying fine but the other columns are not

    URN         Expr1001        Expr1002
    221203      CanX Reason     Date to take effect?
    224774      CanX Reason     Date to take effect?
    225311      CanX Reason     Date to take effect?
    221184      CanX Reason     Date to take effect?
    222699      CanX Reason     Date to take effect?
    223932      CanX Reason     Date to take effect?

Is there a way to correct this behaviour?

You don't put single quotes around field names. Because your names have embedded blanks try putting the field names inside square brackets as in [my field name]. When you say

SELECT myfield

what gets returned is the value of myfield for all records. When you specify a literal like

SELECT 'this string'

what gets returned is the string 'this string'. It's like the difference between "print the value of x" and "print the value of 5"

Great. Makes sense. Thanks Reverend Jim.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.