Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SQL querey from C# to Pervasive fails in two word column name

SQL querey from C# to Pervasive fails in two word column name

SQL querey from C# to Pervasive fails in two word column name

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 (white space in middle). 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"
If I browse the database with visual studio, I can see the data as well.

thanks for your help!

RE: SQL querey from C# to Pervasive fails in two word column name

You need to surround the field name with double quotes in C# too.  
For example:


string queryString = "SELECT \"Appt Date\" FROM Appointment"

Certified Pervasive Developer
Certified Pervasive Technician

RE: SQL querey from C# to Pervasive fails in two word column name

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"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close