Home > Back-end >  Turn an error ADOQuery1: Field 'dis_no' not found
Turn an error ADOQuery1: Field 'dis_no' not found

Time:09-22

Procedure TOManage. Button4Click (Sender: TObject);
Var
I, k, m: integer;
Ordno tabno, tabname, disno disname, disprice, SQL: string;
The begin
K:=0;
While iIf listbox3. Selected [I] then
The begin
The for m:=0 to listbox2. Items. Do the Count - 1
With adoquery1 do
The begin
K:=k + 1;
Ordno:=inttostr (k);
Tabname:=listbox3 Items [I];
Disname:=listbox2 Items [m].
Adoquery1. Close;
Adoquery1. Sql. The Clear;
Adoquery1. Sql. The Add (' select dis_No from dish where dis_Name=disname ');//error

Disno:=FieldByName (' dis_No). The Value;
Adoquery1. Open;
Adoquery1. Close;
Adoquery1. Sql. The Clear;
Adoquery1. Sql. The Add (' select dis_Price from dish where dis_Name=disname ');
Disprice:=FieldByName (' dis_Price). The Value;
Adoquery1. Open;
Adoquery1. Close;
Adoquery1. SQL. The Clear;
Adoquery1. Sql. The Add (' select tab_no from dish where tab_name like tabname ');
Tabno:=FieldByName (' tab_no). The Value;
SQl. Text:="insert into the orders (ord_no, tab_no tab_name, dis_No, dis_Name, dis_Price) values (' + ordno + ', '+ tabno +', '+ tabname +', '+ disno +', '+ disname +', '+ disprice +') '.
Adoquery1. Execsql;
End
End
The else
I:=I + 1;
end;

CodePudding user response:

Adoquery1. Sql. The Add (' select dis_No from dish where dis_Name='+ quotedstr (disname));

CodePudding user response:

The select dis_No from dish where dis_Name=' 'disname' '

CodePudding user response:

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Adoquery1. Close;
Adoquery1. Sql. The Clear;
Adoquery1. Sql. The Add (' select dis_No from dish where dis_Name=disname ');//error

Disno:=FieldByName (' dis_No). The Value;
Adoquery1. Open;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Above is your code
The third line in 1 # under the replacement of
The bottom line and the penultimate line switching,

CodePudding user response:

Parameter disname cannot directly in the middle of the string quotes' directly from, how do you know use string concatenation, behind the front don't have to!
Add (' select dis_No from dish where dis_Name=' ' '+ disname +' ' ' ')

CodePudding user response:

 
Adoquery1. Sql. The Add (' select dis_No from dish where dis_Name='" + trim (disname) + "' ");

CodePudding user response:

SQL statements written in any error, need to pay another temp initialization, otherwise the system will pay for initial value, affect the data comparison result,

CodePudding user response:

reference 5 floor kye_jufei reply:
 
Adoquery1. Sql. The Add (' select dis_No from dish where dis_Name='" + trim (disname) + "' ");
should be reference variables, error-prone, support the fifth floor,

CodePudding user response:

The 3 + 4 floor method can handle
  • Related