Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement problem 1

Status
Not open for further replies.

ziggs

Technical User
Sep 21, 2000
195
US
Here's what won't work:

SQL = "Select * from TBL-CASES"
set rs = my_conn.Execute(SQL)

However if I change the name in the database from TBL-CASES to CASES, it will work. Thus, I'm thinking it doesn't like the hyphen.

I can't really change the Database design. So, how can I include the hyphen in Select statement?

 

ziggs,

You got that right! Use

SQL = "Select * from [TBL-CASES]"
set rs = my_conn.Execute(SQL)




fengshui1998
 
Hmmm, it didn't work. I must be missing something. Again, if I changed the database table to CASES instead of TBL-CASES, it seemed to work for some unknown reason. I was taking a guess that I needed to insert different characters in the SQL langauge to replace the hyphen.
 
yes, it's a hyphen, aka/ minus sign. That might be my problem and since it's not my database to change, I can't do a thing until I solve this problem. Thanks
 

ziggs,

I have an SQL database that has tables with hyphens and this works fine.

strSQL = "SELECT * FROM [" & tbl & "]"

Maybe Access does not like columns with hyphens but SQL does?

fengshui1998
 
if you have access to the database, try making a query using the query designer. see what format the - gets put in... it's possible that [table-name] won't work, but table\-name might...

 
Strange....I tried your code and connected to both Access97 and SQL Server 7 just fine. I had to surround the TBL-CASES with [] just as FengShui1998 stated but after that everything worked. I don't know what could be causing your code to not work properly. :(
 
I don't know if it makes a difference but what is your connection string ziggs?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top