dcsimg
Results 1 to 3 of 3

Thread: Could not find specified column in results

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    105

    Could not find specified column in results

    Hi

    I try to insert the code but I get error so I upload it as png image

    how can I get ID3 to reader("ID3").ToString I get this error

    System.IndexOutOfRangeException: 'Could not find specified column in results: ID3


    Name:  code.jpg
Views: 148
Size:  23.0 KB


    Regards
    ssaloomn

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,096

    Re: Could not find specified column in results

    When you do a UNION the column names are generally (it varies by database system) based on the column names from the first query - so in this case you have ID1 and TP1.

    If you want to be able to tell which query the values came from, add a dummy field which you give different values to, eg:
    Code:
    SELECT '1' as queryNum, t1.ID ID1, ...
    ...
    SELECT '2' as queryNum, t3.ID ID1, ...
    note however that this may increase the amount of records returned, because a UNION filters out duplicates (unlike a UNION ALL), and this dummy field will ensure that records from the different queries will not match each other.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    105

    Re: Could not find specified column in results

    Thanks si_the_geek

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width