procedure TOManage.Button4Click(Sender: TObject);
var
i,k,m: integer;
ordno,tabno,tabname,disno,disname,disprice,sql:string;
begin
k:=0;
while i<listbox3.Items.Count do
if listbox3.Selected[i] then
begin
for m:=0 to listbox2.Items.Count-1 do
with adoquery1 do
begin
k:=k+1;
ordno:=inttostr(k);
tabname:=listbox3.Items[i];
disname:=listbox2.Items[m];
adoquery1.Close;
adoquery1.Sql.Clear;
adoquery1.Sql.Add('select dis_No from dish where dis_Name=disname');//出错 disno:=FieldByName('dis_No').Value;
adoquery1.Open;
adoquery1.Close;
adoquery1.Sql.Clear;
adoquery1.Sql.Add('select dis_Price from dish where dis_Name =disname');
disprice:=FieldByName('dis_Price').Value;
adoquery1.Open;
adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.Sql.Add('select tab_no from dish where tab_name like tabname');
tabno:=FieldByName('tab_no').Value;
SQl.Text:='insert into orders(ord_no,tab_no,tab_name,dis_No,dis_Name,dis_Price) values('+ordno+','+tabno+','+tabname+','+disno+','+disname+','+disprice+')';
adoquery1.execsql;
end
end
else
i:=i+1;
end;
var
i,k,m: integer;
ordno,tabno,tabname,disno,disname,disprice,sql:string;
begin
k:=0;
while i<listbox3.Items.Count do
if listbox3.Selected[i] then
begin
for m:=0 to listbox2.Items.Count-1 do
with adoquery1 do
begin
k:=k+1;
ordno:=inttostr(k);
tabname:=listbox3.Items[i];
disname:=listbox2.Items[m];
adoquery1.Close;
adoquery1.Sql.Clear;
adoquery1.Sql.Add('select dis_No from dish where dis_Name=disname');//出错 disno:=FieldByName('dis_No').Value;
adoquery1.Open;
adoquery1.Close;
adoquery1.Sql.Clear;
adoquery1.Sql.Add('select dis_Price from dish where dis_Name =disname');
disprice:=FieldByName('dis_Price').Value;
adoquery1.Open;
adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.Sql.Add('select tab_no from dish where tab_name like tabname');
tabno:=FieldByName('tab_no').Value;
SQl.Text:='insert into orders(ord_no,tab_no,tab_name,dis_No,dis_Name,dis_Price) values('+ordno+','+tabno+','+tabname+','+disno+','+disname+','+disprice+')';
adoquery1.execsql;
end
end
else
i:=i+1;
end;
解决方案 »
- createOleObject('Excel.Application');运行报错
- ==========GetEnvironmentVariable如何正确使用(顺祝大家十一快乐)====================
- ado连接远程sql数据库
- idhttp登录网页的问题
- 在delphi中有类似于VB的vsflex的组件吗?
- 本地数据库的数据库密码怎么设置?
- 希望熟悉Delphi的朋友回答,谢谢!
- 各位大侠,请问这个问题怎么解决?问题解决马给分,在线等!
- 我的var Reg: TRegistry;总是会?(急电)
- 推荐一个最好的delphi的网站吧,要控件,文章最全的
- DELPHI 开发微信支付
- XE7 自带正则 tRegEx.Matches匹配3000个 超出内存
adoquery1.Close;
adoquery1.Sql.Clear;
adoquery1.Sql.Add('select dis_No from dish where dis_Name=disname');//出错 disno:=FieldByName('dis_No').Value;
adoquery1.Open;
//-------------------------------------------------------------------------
以上是你的代码
第三行用1#的替换下
倒数第一行和倒数第二行交换一下。
Add('select dis_No from dish where dis_Name=’‘‘+disname+’’‘‘)
adoquery1.Sql.Add('select dis_No from dish where dis_Name='''+ trim(disname)+''' ');