procedure TForm1.Button2Click(Sender: TObject);
begin
update;
close;
adoquery1.SQL.Clear ;
adoquery1.SQL.Add('insert into id set *');
adoquery1.SQL.Add('values(':id,:name,:tele')'); //这个语句
adoquery1.Parameters.ParamByName('id').Value :=strtoint(edit2.Text);
adoquery1.Parameters.ParamByName('name').Value :=edit3.Text ;
adoquery1.Parameters.ParamByName('tele').Value :=edit4.Text ;
adoquery1.ExecSQL ;
end;
编译出问题,请你们交我一下,我是菜鸟
begin
update;
close;
adoquery1.SQL.Clear ;
adoquery1.SQL.Add('insert into id set *');
adoquery1.SQL.Add('values(':id,:name,:tele')'); //这个语句
adoquery1.Parameters.ParamByName('id').Value :=strtoint(edit2.Text);
adoquery1.Parameters.ParamByName('name').Value :=edit3.Text ;
adoquery1.Parameters.ParamByName('tele').Value :=edit4.Text ;
adoquery1.ExecSQL ;
end;
编译出问题,请你们交我一下,我是菜鸟
空一格?
1.id是关键字,最好不要用来做字段名,如果要用,就加上[],用[id],
2.insert into [id] (fd1,fd2,fd3)values(:fd1,:fd2,:fd3)
应该是:
ADOQuery1.SQL.Add(' insert into [id] (fd1,fd2,fd3)values(:fd1,:fd2,:fd3) ');
不用在里面加分号,
3.delphi中没有字符,如果想向字符串中传递一个分号,应该用两个分号,如
字符串''''的值就是一个分号,长为1。