fieldname error

I am trying to insert EstimateID from customerinfo table into EstimateID in lineitem table.
I know the field EstimateId is in the table customer info and I know the field EstimateID is tin the table lineitems.
But for some reason I get error say Field EstimateID is not found in customerinfo table.
My  sql is simple select * from customerinfo.

What is wronge here....?
var
sum,l,w,d  : double;
begin
  l:= strToFloat(dbedit3.Text);
  w:= strToFloat(dbedit4.Text);
  d:= strToFloat(dbedit5.Text);
  sum := (2*l*w) + (2*w*d) + (2*l*d);
  dbedit6.Text:= floattostr(sum);
  Sum:= Sum * strToFloat(frmsetup.Edit5.text);
  dbedit7.Text := Format('%.2f',[sum]);
  dbnavigator1.BtnClick(nbPost);
  datamodule1.AQlineitems.Edit;
  datamodule1.AQcustomerinfo.Edit;
  datamodule1.AQlineitems.FieldByName('EstimateID').AsInteger:=  Datamodule1.AQcustomerinfo.fieldbyname('EstimateID').AsInteger;
         datamodule1.AQlineitems.FieldByName('CustomerID').AsInteger:=datamodule1.AQcustomerinfo.fieldbyname('CustomerId').AsInteger;<<<<<<<Crashes Here
end;

Open in new window

Grant FullenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Grant FullenAuthor Commented:
Same thing if i try simple insert ...........
with datamodule1.AQcustomerinfo do
  try
    if active then
      close;
    SQL.Text := 'INSERT INTO lineitems (EstimateID) VALUES (:ID)';
    Parameters.ParamByName('ID').Value := Datamodule1.AQcustomerinfo.fieldbyname('EstimateID').AsInteger;
    ExecSQL;
  finally
    Close;

Open in new window

0
moorhouselondonCommented:
Double-click on the AQcustomerinfo component to get the list of fields up.  Is estimateid defined in the list?
0
Geert GOracle dbaCommented:
try this to see if that field exists:

function DataModule1.FieldExists(TableName, FieldName: string): boolean;
var Qry: TQuery;
begin
  Qry := TQuery.Create(Self);
  try
    Qry.Database := 'xxx'; // attach to database alias
    Qry.SQL.Text := Format('SELECT * FROM %s WHERE 1 = 0', TableName);
    Qry.Open;
    Result := Qry.FindField(FieldName) <> Nil;
    Qry.Close;
  finally
    FreeAndNil(Qry);
  end;
end;

then to check:

  if not DataModule1.FieldExists('CUSTOMERINFO', 'ESTIMATEID') then
    ShowMessage('Field ESTIMATEID does not exist in CUSTOMERINFO');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Geert GOracle dbaCommented:
did you add some fields, by using right click editor, add fields
and then not add the ones you created last in the database
by using add missing fields
0
8080_DiverCommented:
My  sql is simple select * from customerinfo
Instead of your SQL statement with the asterisk, try specifying the list of columns (including the one that is indicated as not being there).  Then, try opening the SQL statement.  If you can still successfully open the statement, then your field does exist with that name.  On the other hand, if the Open fails, your field either doesn't exist in that table or doesn't exist with that name.  (It may be that there is a typo in the field name.)
You didn't mention the DBMS that you are using.  There may be issues involving the particular DBMS.  For instance, if you are accessing a Case Sensitive isnstance of certain DBMS, you might have an issue of "EstimateID" in your program and "EstimateId", "estimateID", "estimateid", "Estimateid", or even "ESTIMATEID" in the DBMS for the column name.  
IT is usually a wise choice to notuse the asterisk in your queries and, instead, to actually list the columns you want to retrieve.
0
Grant FullenAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.