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 9046421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:39:34+00:00 2026-06-16T11:39:34+00:00

I have compiled a string that queries a database like so: stringCompiler = SELECT

  • 0

I have compiled a string that queries a database like so:

stringCompiler = "SELECT * FROM SomeTable";

The problem is that some of the columns have spaces in their names (i.e., “City Tag Number”).

How can I call this later after I use the db.Query statement. Example:

foreach(var row in db.Query(stringCompiler))
{
    var someVariable = row.Column With Spaces;
}

Obviously the above code would produce an error.

I could go through each column instead of using ‘ * ‘, all the while assigning aliases to all of the column names with spaces in them. Example:

stringCompiler = "SELECT \"City Tag Number\" AS CityTagNumber, ...";

But there are a lot of column names in this table and I am assuming there is a better way, and that I just can’t find it (I promise, I’ve looked).

Any help is much appreciated.

—————-EDIT————————

I should’ve specified that I was using SqlServer.

  • 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-06-16T11:39:35+00:00Added an answer on June 16, 2026 at 11:39 am

    In a sql text passed to the DB engine, usually (but it depends on the actual db) you use square brackets (SqlServer, Access) or backticks (mysql)

     stringCompiler = "SELECT [City Tag Number] AS CityTagNumber, ...";
    
     stringCompiler = "SELECT `City Tag Number` AS CityTagNumber, ...";
    

    while in code (assuming row is a DataRow) you use the name of the column as string

    foreach(var row in db.Query(stringCompiler))
    {
        var someVariable = row["City Tag Number"].ToString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that is saved to a database that is compiled by
So in microsoft visual studio I have a string that is compiled into a
Have a LinqtoSql query that I now want to precompile. var unorderedc = from
I have to make some heavy queries in my datastore to obtain some high
I've got a string that has curly quotes in it. I'd like to replace
I am trying to chain multiple compiled linq queries together. I have succeeded in
I have a large program with several large DLL's that are compiled with MFC
I have a C code in long file that is compiled using cc. But
I have a servlet with several methods that get a list of objects from
How can I compile a string from selected rows of a file, run some

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.