haci aliyev
haci aliyev

Reputation: 97

adoquery1: parameter 'firstname' not found

I am new to Delphi. I get this error every time I run things:

adoquery1: parameter 'firstname' not found

procedure TForm1.Button1Click(Sender: TObject);

begin

ADOQuery1.Close;

ADOQuery1.sql.Clear;

ADOQuery1.SQL.Text:=Memo1.Text; 
  //( in memo  I wrote this codes "insert into adlar (firstname) values(:edit1)")


ADOQuery1.Parameters.ParamByName('firstname').Value:=Edit1.Text;

ADOQuery1.ExecSQL;

Upvotes: 1

Views: 141

Answers (1)

MartynA
MartynA

Reputation: 30715

ADOQuery1.SQL.Text:=Memo1.Text; //( in memo I wrote this codes "insert into adlar (firstname) values(:edit1)")

Well, if that's what is in Memo1.Text, the SQL doesn't contain a parameter named "firstname", it has a parameter named "edit1" instead, so unless you already have a persistent parameter (created in the IDE using the Object Inspector) with that name, you will get that error.

Try it with Memo1.Text containing:

insert into adlar (firstname) values(:firstname)

Or else change the name you are passing to ParamByName():

ADOQuery1.Parameters.ParamByName('edit1').Value:=Edit1.Text;

Upvotes: 3

Related Questions