Solved

TQuery SQL EDBEngineError

Posted on 2002-03-05
6
258 Views
Last Modified: 2010-04-05
Hi Experts,

I tried to make a SQL application and I have got the EDBEngineError message: General SQL error [Microsoft][ODBC Microsoft Access Driver]Syntax error (missing operator) in query expression in query expression 'Country where country >= F'.'.
There is a DataModule with Query1: TQery and the SQL-phrase is :
Query1.SQL.Add('select * from Country order by COUNTRY where COUNTRY >= ' + EditBox1.Text;
 
Something interesting is the end of error phrase: quote - point - qoute
meikl told me to replace the
 
EditBox1.text

with

ansiquotedstr(EditBox1.Text,'"')
 
but the resulted error message was the same.

Could somebody give me a new idea? I try to give more points later but now I have only this ten.

wbr

Janos
0
Comment
Question by:kacor
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6841458
hi janos,

regarding to your last screenshot you sent me,
you've missed a bracket ) before the ;

query1.sql.add('select * from atable where afield >= '+ansiquotedstr(AString,'"'));

about your statement above the order by clause must be behind the where-clause

select ...FieldList
  from ...TableList
 where ...Conditions
 order by ...FieldList

meikl ;-)

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6841465
btw. you could also use parameters
instead of rebuild the sql-string allways.

0
 
LVL 4

Accepted Solution

by:
jsweby earned 20 total points
ID: 6841925
The error is because the ORDER BY clause is before the WHERE clause. The best syntax for this operation is:

Query1.SQL.Append('SELECT * FROM Country WHERE Country >= :sCountry ORDER by COUNTRY');
Query1.ParamByName('sCountry').AsString :=EditBox1.Text;

This is assuming, of course, that Country is a text field in a table called Country.

J.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Author Comment

by:kacor
ID: 6847710
Hi, I had no internet connection til now

Tnx your help

tonight  i'll try to read the messages

wbr

Janos
0
 
LVL 10

Author Comment

by:kacor
ID: 6854185
Hi meikl and jsweby,

many thanks for helping me.

jsweby,

it works perfectly but first I forgot to insert : before the paramameter name :-))

meikl,

something I make wrong but the offered solution don't work. Today I would like to have a good result using your offered solution because it interests me and the result will be submitted

Janos
0
 
LVL 10

Author Comment

by:kacor
ID: 6854186
Thanks jsweby

Janos
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now