Link to home
Start Free TrialLog in
Avatar of Grant Fullen
Grant Fullen

asked on

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

Avatar of Grant Fullen
Grant Fullen

ASKER

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

Double-click on the AQcustomerinfo component to get the list of fields up.  Is estimateid defined in the list?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
Thanks