with adoquery3 do
   begin
       close;
       sql.Clear;
       sql.Text:='insert into fuser(username,password1,right)values(:ausername,:apassword1,:aright)';
       Parameters.ParamByName('ausername').Value:=edit1.Text;
       Parameters.ParamByName('apassword1').Value:=edit2.Text;
       Parameters.ParamByName('aright').Value:=combobox1.Text;
       ExecSQL;
       messagedlg('添加成功!',mtinformation,[mbOK],0);
   end;

解决方案 »

  1.   

    right是一个SQL函数,用作字段名时要加[],变成[right]
      

  2.   

    sql.Text:='insert into fuser(username,password1,right) values(:ausername,:apassword1,:aright)';
      

  3.   

    sql.Text:='insert into [fuser]([username],[password1],[right]) values(:ausername,:apassword1,:aright);';
      

  4.   

    right是关键字,内部函数,从右取几个字符
      

  5.   

    right是一个SQL函数,从右取几个字符,用作字段名时要加[],写成[right]
      

  6.   

    参数的赋值不要直接用.value,而要针对不同的类型,使用asString,asInteger...
    因为直接使用value的时候delphi无法判断参数的类型。你看源码就知道了。
      

  7.   

    我最不喜欢用那个 Parameters了,看着一大堆,而且那个参数还要加 “:”,繁琐。  with ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Text := 'insert into table1(ID, Name, Sex) values('''+Edit1.Text+''', '''+Edit2.Text+''', '+IntToStr(ComboBox1.ItemIndex)+')';
        ExecSQL;
      end;可以不?