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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error both VB & SQL

Status
Not open for further replies.

rgb30b

Technical User
May 9, 2003
19
US
I was trying to connect database with a '-' in its name eg;
DatabaseName E-CPT, Tablename Machine. I was actually trying to validate that a machine was in the table from VB eg; "Select machine_id from machine where machine_id = "' & machine. Im getting syntax errors, all relating to the '-' dash in VB and ISQL. Am I missing something connecting to a DB with a dash in the Database-name.table.

Thankx in advance, and pardon the ignorance...
 
Try putting "[" and "]" around the offending text:

SELECT * FROM Some-Table

will fail, but

SELECT * FROM [Some-Table]

won't.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Thankx for the reply Andy, however I still have a problem. Perhaps I was not clear earlier. The dashed name is the database not the tablename. I must admit, I have never seen a database named with a '-' , E-CPT. In Query Analyzer for instance "select * from e-cpt..machine, and "select * from [e-cpt..machine] and ...'"e-cpt..machine"' and ...'everything else..machine' Ive tried still says incorrect syntax. In VB my DSN is pointed to the server without a default database. I can connect and poll the other databases..tables using it. By the way I've created a new DSN pointing directly to E-CPT database and it still does not work. I wonder if it is a default setting somewhere? Thankx in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top