gpt4 book ai didi

sql - Adoquery1 : CommandText does not return a result set

转载 作者:行者123 更新时间:2023-12-03 18:04:07 25 4
gpt4 key购买 nike

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.

来源:http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ADODB_TADOQuery_ExecSQL.html

在表中插入值使用:

  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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com