Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2521
  • Last Modified:

Error Message : Query '<field name>' is not found

Dear Advisor !

There is a TADOQuery on TFrom. I use TADOQuery to get data  in some cases. Like that

ADOQuery.Active := False
ADOQuery.SQL.Clear
ADOQuery.SQL.Add('<SQL Statemen>')
ADOQuery.Parameters.ParamValues['<filed name>'] := <value> ;
ADOQuery.Open

TEdit1.Text := ADOQuery.FieldValues[<Field 1>']
TEdit2.Text := ADOQuery.FieldValues[<Field 2>']   {Line is marked error}
TEdit3.Text := ADOQuery.FieldValues[<Field 3>']


There is no error . But  sometime, when i assign value to TEdit, it makes a error. Sometime, ADOQuery remembers the old SQL Statement ?

Query  '<field name>' is not found

Althought, i use "select * from" in SQL Statement, or indicate each fields

Thanks for all consider
0
NamCit
Asked:
NamCit
  • 3
  • 3
1 Solution
 
CrazyOneCommented:
I don't know if this will help with your problem but instead of using the FieldValues property try doing this instead

ADOQuery.FieldByName('<Field 1>').AsString;

FieldValues is a variant and as such the system needs to figure out what the type is of the variant and convert it, which causes more overhead and slows down the process. If you use FieldValues a lot in a project and then replace it with FieldByName you would probably notice the improvement in performance.

Also as a personal preference I instead of using
ADOQuery.Active := False

I use
ADOQuery.Close;

I don't think it matters one way or the other but for me it is easier to do and read. :>)
0
 
CrazyOneCommented:
Please provide a few examples of your SQL statement especially on the one(s) when the error ocurrs. I suspect that is where the problem is.
0
 
NamCitAuthor Commented:

Dear Sir !

I have modified muy code so much, so now i dont get thet error again.

i will use FieldByName like your comment.


0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
NamCitAuthor Commented:

Thanks so much.

I hope to receive more your consider in future
0
 
CrazyOneCommented:
:>)
0
 
NamCitAuthor Commented:

I hhave a new question in forum

{
I use Delphi 5.0

TDBGRID is moved (be wriggled), when i retrieve new data from Table.

I also used InputForm.OrderTable.DisableConTrol. But it is not effcted.
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now