Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:15:46+00:00 2026-05-26T22:15:46+00:00

My Access query is returning fields out of order. It was my understanding that

  • 0

My Access query is returning fields out of order. It was my understanding that for each row from the query result the fields would be in the same order that were specified in the query’s SELECT statement. What am I doing wrong?

        String query =
            "SELECT " +
                "bas.[BAS BACnet Object Type/Instance], " +
                "bas.[BAS BACnet Object Name], " +
                "bas.[BAS Point List Description], " +
                "ore.[ORE Data Direction], " +
                "ref.[ENUM_H], " +
                "yk.[CCC Max Value (eng units)], " +
                "yk.[CCC Min Value (eng units)], " +
                "yk.[CCC Enum/Data Set], " +
                "ore.[ORE COV Increment], " +
                "ore.[ORE Display Precision] " +
            "FROM (([OV2 BAS] AS bas " +
            "INNER JOIN [OV2 ORE] AS ore ON bas.[Ref ID] = ore.[Ref ID]) " +
            "INNER JOIN [OV2 RefID] AS ref ON bas.[Ref ID] = ref.[Ref ID]) " +
            "INNER JOIN [YK CAPP] AS yk ON bas.[Ref ID] = yk.[Ref ID] " +
            "WHERE bas.[BAS BACnet Object Type/Instance] <> '';";

        try
        {
            cmd = new OleDbCommand(query, this._conn);
            reader = cmd.ExecuteReader();

            if (reader.HasRows == false)
            {
                Exception e = new Exception("Read of mapping table returned no results.");
                throw e;
            }

            while (reader.Read() != false)
            {
                Int32 columns;
                Object[] fields = new Object[10];

                columns = reader.GetValues(fields);

                avClass = new AVClass();

                for (int i = 0; i < AVClass.AV_CLASS_PROPERTIES; i++)
                {
                    avClass.Properties[i] = new AVProperty((AVProperty.PROPERTY_ID)i, fields[i]);
                    results.Add(avClass);
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("ERROR: " + e.Message);
            Console.WriteLine(e.ToString());
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:15:46+00:00Added an answer on May 26, 2026 at 10:15 pm

    Well it’s not clear whether it’s the only problem, but this looks wrong to me:

    for (int i = 0; i < AVClass.AV_CLASS_PROPERTIES; i++)
    {
        avClass.Properties[i] = new AVProperty((AVProperty.PROPERTY_ID)i, fields[i]);
        results.Add(avClass);
    }
    

    You’re adding the same reference (avClass) to your results list for every field. I suspect you want to put that Add call after the loop.

    Also, you haven’t shown what AVProperty.PROPERTY_ID is, but you’d need make sure that the SELECT part of the query matches that. Presumably it’s an enum… so you’d need the enum value corresponding to “bas.[BAS BACnet Object Type/Instance]” to have value 0, etc.

    (If you can give more of the relevant code, we may be able to help you more. I’d also strongly recommend that you go through your code and make your names more self-explanatory and idiomatic. .NET doesn’t use SHOUTY_CAPS for names.)

    Additionally:

    • You’re not using using statements for any of the objects which should be disposed
    • You’re ignoring the value returned from GetValues.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that is returning a single result and I'm wondering if
Here is my access query that I have. Every value that I return is
Can this MS-Access query be improved? i.e. the SELECT TOP 1 col FROM Table2
I have the following Access query: SELECT [city] FROM [patient] WHERE REPLACE([patient].[city],' ',' ')
I would like to achieve something very similar to Microsoft Access query designer -
Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
I'm running a query that looks like this: $results = $DB2->query(SELECT COUNT(*) FROM auth_user
I have the following data structure returning from a Yahoo API: cbfunc({ query: {
When I search the same query using the Twitter API returning JSON content and
Is there a simpler way of returning the relationship row from a table to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.