- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.close;
ADOQuery1.SQL.text:='insert into veresiye (product,price,piece,total)
VALUES (:par0,:par1,:par2,:par3)';
ADOQuery1.Parameters.ParamByName('par0').Value:=Edit1.Text;
ADOQuery1.Parameters.ParamByName('par1').Value:=Edit2.Text;
ADOQuery1.Parameters.ParamByName('par2').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('par3').Value:=Edit4.Text;
ADOQuery1.Open;
ADOQuery1.ExecSQL;
end;
我收到此错误消息:
Adoquery1: CommandText does not return a result set
为什么会出现此错误,我该如何解决?
最佳答案
Call ExecSQL to execute the SQL statement currently assigned to the SQL property. Use ExecSQL to execute queries that do not return a cursor to data (such as INSERT, UPDATE, DELETE, and CREATE TABLE).
ExecSQL returns an integer value reflecting the number of rows affected by the executed SQL statement. Note: For SELECT statements, call Open instead of ExecSQL or set the Active property to true. To speed performance, an application should ordinarily prepare the query by setting the Prepared property to true before calling ExecSQL for the first time.
在表中插入值使用:
ADOQuery1.close;
ADOQuery1.SQL.text:='insert into veresiye (product,price,piece,total)
VALUES (:par0,:par1,:par2,:par3)';
ADOQuery1.Parameters.ParamByName('par0').Value:=Edit1.Text;
ADOQuery1.Parameters.ParamByName('par1').Value:=Edit2.Text;
ADOQuery1.Parameters.ParamByName('par2').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('par3').Value:=Edit4.Text;
ADOQuery1.ExecSQL;
要从表中获取值,请使用:
ADOQuery1.close;
ADOQuery1.SQL.text:='select * from veresiye';
ADOQuery1.Open;
关于sql - Adoquery1 : CommandText does not return a result set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37460195/
我是一名优秀的程序员,十分优秀!