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

SQL statement

Status
Not open for further replies.

Wings

Programmer
Joined
Feb 14, 2002
Messages
247
Location
US
Hi,
When i try to execute the following sql statement I get a syntax error. Does any one see a problem?

String x = "Select * from CrewTable where PlatoonId = " + QuotedStr(DBPlatoonID->Text) + " AND VehicleID NOT = " + QuotedStr(DBVehicleID2->Text)
+ " AND VehicleID NOT = " + QuotedStr(DBVehicleID3->Text) + " AND VehicleID NOT = " + QuotedStr(DBVehicleID4->Text);

QryPlatoon1->SQL->Add(x);

QryPlatoon1->ExecSQL();
 
Have you tried using the SQL Explorer?
What the error exactly says?

--- LastCyborg ---
 
I think you need parenthesis as well around your where clause.
 
if QuotedString returns the text within single quotes you are fine... otherwise you need to make a SingleQuotedString function which will use the ' instead of "

Matt
 
Thanks for the help, actually the sql was fine, I needed to call Open() instead of ExecSQL().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top