473,508 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2810
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
583
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
2083
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
2364
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
6356
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
2717
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
6425
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
4065
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
5070
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
2729
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
3606
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
7115
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
7377
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...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.