473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

select statements

I have a select statement like this:
string Select = "Select TableofContents, DataOwner, Delegates From NYC";

and it work fine, but if I was to put a space in like this:
string Select = "Select Table of Contents, Data Owner, Delegates From NYC";

I would get an error in my da.fill(ds);

Why can I not use a space in my select statement. I have to connect to a db,
but I can not change it.
Nov 16 '05 #1
5 2804
string Select = "Select [Table of Contents], Data Owner, Delegates From
NYC";

"freddy" <fr****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
I have a select statement like this:
string Select = "Select TableofContents, DataOwner, Delegates From NYC";

and it work fine, but if I was to put a space in like this:
string Select = "Select Table of Contents, Data Owner, Delegates From
NYC";

I would get an error in my da.fill(ds);

Why can I not use a space in my select statement. I have to connect to a
db,
but I can not change it.

Nov 16 '05 #2
do not work

"Jared" wrote:
string Select = "Select [Table of Contents], Data Owner, Delegates From
NYC";

"freddy" <fr****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
I have a select statement like this:
string Select = "Select TableofContents, DataOwner, Delegates From NYC";

and it work fine, but if I was to put a space in like this:
string Select = "Select Table of Contents, Data Owner, Delegates From
NYC";

I would get an error in my da.fill(ds);

Why can I not use a space in my select statement. I have to connect to a
db,
but I can not change it.


Nov 16 '05 #3

"freddy" <fr****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
I have a select statement like this:
string Select = "Select TableofContents, DataOwner, Delegates From NYC";

and it work fine, but if I was to put a space in like this:
string Select = "Select Table of Contents, Data Owner, Delegates From NYC";
I would get an error in my da.fill(ds);

Why can I not use a space in my select statement. I have to connect to a db, but I can not change it.


The short answer is that the names in your query must match the table and
field names defined in the database.
You cannot decide to introduce spaces in the names when you write the query.
What database are you using?
I believe the question is whether or not the database you are querying
allows spaces in table and field names.
The solution of enclosing the name in [] if there are spaces works OK in an
Access database, but many databases will not permit spaces in names.
Jared's response indicating use of [] should work in an Access database if
you have filed defined in the NYC table with names "Table of Contents" "Data
Owner" and "Delegates".
Freddy's response to Jared that his solution did not work is probably based
on the fact that Jared placed [] around only one of the two field names that
contain embedded spaces.
OTOH, Oracle would not have permitted field names with embedded spaces in
the first place.
IMHO, using table and field names with embedded spaces (even if permitted by
the DBMS) is a poor practice that will end up causing far more trouble than
it saves.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #4
OTOH, Oracle would not have permitted field names
with embedded spaces in the first place.
YES it does - you must wrap the column or table name with double quotes.

Consider something like this:

CREATE TABLE "my stuff"{
"first name" VarChar2(30),
"last name" VarChar2(30))
TABLESPACE USERS
STORAGE(INITIAL 1M NEXT 1M PCTINCREASE 0)
/

SELECT "first name" FROM "my stuff"

and

SELECT *
FROM USER_TAB_COLS
WHERE TABLE_NAME='my stuff'
IMHO, using table and field names with embedded spaces (even if permitted by the DBMS) is a poor practice that will end up causing far more trouble than it saves.
I agree 100 percent!!!

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 16 '05 #5
In SQL Server, you need to you [] just as Jared said. Maybe you use a
different DB - what is ur DB?

"freddy" wrote:
do not work

"Jared" wrote:
string Select = "Select [Table of Contents], Data Owner, Delegates From
NYC";

"freddy" <fr****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
I have a select statement like this:
string Select = "Select TableofContents, DataOwner, Delegates From NYC";

and it work fine, but if I was to put a space in like this:
string Select = "Select Table of Contents, Data Owner, Delegates From
NYC";

I would get an error in my da.fill(ds);

Why can I not use a space in my select statement. I have to connect to a
db,
but I can not change it.


Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hans Maurer | last post by:
>Description: We're running our current TTS application with MySQL (on Unix). All database, table and column names are in lower-case. However, we need to access this database with a new...
1
by: alexqa2003 | last post by:
got a table with (class, name, exam, score) fields. To find max(score) for exam that starts with letter 'm' grouped by class and name,did: select max(score) from #temp where exam like 'm%'...
3
by: Leader | last post by:
Hi All, I am getting slower performance of select statements in MS SQL. I am finding select statements in MS SQL are even slower than MS ACCESS. Is there any way to improve the performance of...
2
by: Edwinah63 | last post by:
Hi Everyone, All the very best for 2004!! i need urgent help with this problem, the users are about to skin me alive!! we have an access front end with linked to sql server 2k tables. ...
15
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
4
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement...
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add...
5
by: sijugeo | last post by:
Hi, I am using SQL SERVER 2005. I have two select statements. The code is given below. -----------1.-------------------------- select d.idx_Delivery,s.idx_Stops,case FixedFlag when 1...
1
by: bharathi228 | last post by:
How to write two or more select statements in a single query here my requirement is SELECT dbo.SYS_PARAMS.PARAMETER_NAME, dbo.SYS_PARAMS.PARAMETER_UNITS, SYSTEM2.dbo.CALIBRATION.CAL_TYPE, ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.