procedure TForm1.Button1Click(Sender: TObject);
var
pno,pname:string;
begin
self.ADOQuery1.Close;
pno:= edit1.Text;
pname:= edit2.Text;
self.ADOQuery1.SQL.Clear;
self.ADOQuery1.SQL.Add('Insert into b (id,name) values(pno,pname)');
self.ADOQuery1.Open;
end;
编译通过,运行错误
错误提示:在此上下文中不允许使用PNO,此处只允许使用变量,表达式或常量,
不允许使用列名
请问要怎样修改
var
pno,pname:string;
begin
self.ADOQuery1.Close;
pno:= edit1.Text;
pname:= edit2.Text;
self.ADOQuery1.SQL.Clear;
self.ADOQuery1.SQL.Add('Insert into b (id,name) values(pno,pname)');
self.ADOQuery1.Open;
end;
编译通过,运行错误
错误提示:在此上下文中不允许使用PNO,此处只允许使用变量,表达式或常量,
不允许使用列名
请问要怎样修改
self.ADOQuery1.SQL.Add('Insert into b (id,name) values(edit1.text,edit2.text)');
huo pname)');
id是整形
name是字符串
self.ADOQuery1.SQL.Add('Insert into b (id,name) values('+pno+','+''''+pname+''''+')');
var
pno,pname:string;
begin
self.ADOQuery1.Close;
pno:= edit1.Text;
pname:= edit2.Text;
self.ADOQuery1.SQL.Clear;
self.ADOQuery1.SQL.Add('Insert into b (id,name) values('''' + pno + ''',' + '''' + pname+'''')');
self.ADOQuery1.Open;
end;
self.ADOQuery1.SQL.Add('Insert into b (id,name) values('''' + pno + ''',' + '''' + pname+''')');
程序中写 adoquery1.params.paramvalue['id;name']:=
vararrayof([edit1.text,edit2.text]);
self.ADOQuery1.SQL.Add('Insert into b (id,name) values(:id,:name)');
adoquery1.params.paramvalue['id;name']:=vararrayof([edit1.text,edit2.text]);
self.ADOQuery1.SQL.Add('Insert into b (id,name) values
(pno,pname)');
self.ADOQuery1.SQL.Add('Insert into b (id,name) values('''' + pno + ''',' + '''' + pname+''')');