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

Missing Operator using ADO

Status
Not open for further replies.

Tony1l

Programmer
Dec 21, 2002
30
0
0
US
LVL 1 question
I have two lines of code very similar 1 works fine and later changing only the operator causes it to fail.

//working
sql.add('update items set cost = 5 where contract = ''''');
but reverse it with
('update items set cost = 5 where contract != ''''');

Syntax error (missing operator)in query expression 'contract !='''

I also tried (IS NOT NULL) but also fails missing operator.
sql.add('update items set cost = 5 where contract IS NOT NULL');

This (Not Null) statement is valid when directly entering it in Access query but not in my Delphi app. Any suggestions?

 
the correct SQL syntax would be:

'update items set cost = 5 where contract <> '''' '

this will update all records where the contract field is an empty string

please be aware that this query is not the same as

'update items set cost = 5 where contract IS NOT NULL'

this will update all records where the contract field does not exist (ie = null)

what delphi version are you using? and which ADO component?

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Its ok now the <> was the correct syntax. Thanks harebrain & whosrdaddy. You were on track and now so am i.

FYI: Delphi 2007
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top