var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: SQL Select statement for column name that has two words
I am using Visual C# to access a Pervasive v8.6 database via ODBC interface. I can't find the right syntax to Select a column whose name is two words. If the column name is only one word, I'm fine.
Table is: Appointment
One column name is: Appt Date
One column name is: Length
This C# code works when I put it in my data reader
string queryString = "Select Length FROM Appointment";
But if I do this,
string queryString = "Select Appt Date FROM Appointment";
I get a syntax errors. I've tried all kinds of combinations, just not the right one, including:
string queryString = "Select" + "Appt Date" + "FROM Appointment";
string queryString = "Select" ApptDate AS [Appt Date] FROM Appointment";
string queryString = "Select" [Appt Date] = ApptDate FROM Appointment";
I can't change the column names without crashing the program I am trying to access.
If I go into the pervasive control center and enter this command, it works ok:
SELECT "Appt Date" FROM "Appointment"
thanks for your help!
Last edited by dghundt; 04-28-06 at
You need to surround the field name with double quotes in C# too.
string queryString = "SELECT \"Appt Date\" FROM Appointment"
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
I do not answer questions by email. Please post on the forum.
Thanks, your rock!
I used the following string which works well. As you point out, the \ prior to the quote is an escape character that tells C# to use the " literally instead of a delimeter for a string. I added \r\n which gave me a new line.
"SELECT \"Appt Date\", \"Appt Time\", \"Home Phone\"\r\nFROM Appointment"