If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > Query Pervasive Table.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-24-04, 03:55
poknad_03 poknad_03 is offline
Registered User
 
Join Date: Feb 2004
Posts: 4
Red face Query Pervasive Table.

I'm trying to query a Pervasive table with two-word name.

Example: "select * from Table 1"........ but an error always occurs. I try
this: "select * from [Table 1]" but it also doesn't work.

I tried to query other tables but with only a single name and no error occurs. So this is a syntax error in Pervasive.

What is the correct syntax for this. Anybody there who can help me.............
Reply With Quote
  #2 (permalink)  
Old 02-24-04, 07:56
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
You need to use double quote around tables with spaces in the name. So in your example, it should be:
Select * from "Table 1"
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 02-26-04, 01:55
poknad_03 poknad_03 is offline
Registered User
 
Join Date: Feb 2004
Posts: 4
I also ried that but the same error occurs. I'm actually doing the query in Visual Basic. When you try to queyr there, the syntax must be:

"select * from Table 1"............. you need to put open/close double qoute. so if i will try your suggestion it will be:

"select * from "Table 1""........... and 'Syntax Error' occurs..........

Have you already encountered this? THANK YOU VERY for your reply. I appreciate it so much. But I think it's not the right solution to my problem. Thank you again.


Quote:
Originally posted by mirtheil
You need to use double quote around tables with spaces in the name. So in your example, it should be:
Select * from "Table 1"
Reply With Quote
  #4 (permalink)  
Old 02-26-04, 07:53
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
The only double quotes need to be around the table name. What version of Pervasive are you using? What tool are you using to issue the statemtn?
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #5 (permalink)  
Old 02-26-04, 15:34
Dilyias Dilyias is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
You must be new to VB. To include quotes in a string you must use "".

So, try something like this:

sSql = "select * from ""Table 1"""
Reply With Quote
  #6 (permalink)  
Old 02-26-04, 15:35
Dilyias Dilyias is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
ALSO, First verify your queries work in the Sql Data Manager. It's like Query Analyser if you have used Sql Server.
Reply With Quote
  #7 (permalink)  
Old 02-26-04, 20:41
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Another way to specify double quotes in VB would be:
SQL = "Select * from " & chr$(34) & "Table 1" & chr$(34)
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #8 (permalink)  
Old 02-26-04, 20:51
Dilyias Dilyias is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
Quote:
Originally posted by mirtheil
Another way to specify double quotes in VB would be:
SQL = "Select * from " & chr$(34) & "Table 1" & chr$(34)
Yes, but that's sooo much typing! I prefer "" because it is the same in sql (two single quotes) and makes it second nature in both languages..

Of course, all those quotes can get confusing!

Sometime I'd do something like :

q = chr$(34)

sSql = "select * from " & q & "table 1" & q

Last edited by Dilyias; 02-26-04 at 20:57.
Reply With Quote
  #9 (permalink)  
Old 03-02-04, 20:35
poknad_03 poknad_03 is offline
Registered User
 
Join Date: Feb 2004
Posts: 4
OKEY!!!!!! Thank you very much!!!! It already works..... Thank you.
Reply With Quote
  #10 (permalink)  
Old 03-03-04, 02:23
Dilyias Dilyias is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
Quote:
Originally posted by poknad_03
OKEY!!!!!! Thank you very much!!!! It already works..... Thank you.
LOL, ..glad we could be of help!

-Eric
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On