一个listbox2 下面放一个edit17 一个button按钮 
当点击button的时候把edit17的内容显示到listbox2中 并且吧edit17的数据写入表notes的 note项中
以下是代码:procedure Tmain_1.Button18Click(Sender: TObject);
begin
     if edit17.Text <>'' then main_1.ListBox2.items.add(edit17.text);
      begin
     adoquery1.close;
  adoquery1.sql.clear;
  adoquery1.sql.add('insert into notes(note) values('''+edit17.text+''')');
  adoquery1.execsql;
 // showmessage('添加完成!');
     end;
     if edit17.Text ='' then messagedlg('请输入内容',MtError,[mbOK],0); 
end;

解决方案 »

  1.   

    报错 insert into 语法错误
      

  2.   

    一个listbox2 下面放一个edit17 一个button按钮 
    当点击button的时候把edit17的内容显示到listbox2中 并且吧edit17的数据写入表notes的 note项中
    以下是代码:procedure Tmain_1.Button18Click(Sender: TObject);
    begin
         if edit17.Text <>'' then main_1.ListBox2.items.add(edit17.text);
          begin
         adoquery1.close;
      adoquery1.sql.clear;
      adoquery1.sql.add( 'insert into notes(note) values('+
                         QuotedStr(edit17.text)+')');
      adoquery1.execsql;
    如果还出错,可能表字段问题.....
      

  3.   

    是不是notes表有多个字段,并且有的字段不允许为空?
      

  4.   

    数据库中只有两个字段  而且都是可以为空的 属性也都是备注(access做数据库)
      

  5.   

    procedure Tmain_1.Button18Click(Sender: TObject);
    begin
         if edit17.Text <>'' then 
         begin
           main_1.ListBox2.items.add(edit17.text);
          
           adoquery1.close;
           adoquery1.sql.clear;
           adoquery1.sql.add('insert into notes(note) values(:avalue)');
           adoquery1.Parameters.parambyname('avalue').asstring = Edit17.text;
           adoquery1.execsql;
          end;
         if edit17.Text ='' then messagedlg('请输入内容',MtError,[mbOK],0); 
    end;如果这样还出错。检查一下数据库连接是否正确。
      

  6.   

    adoquery1.Parameters.parambyname('avalue').asstring = Edit17.text;-------------------------------------------------------------------
    这句是不是有点问题啊?????这个连数据库应该没有什么问题吧
      

  7.   

    procedure Tmain_1.Button18Click(Sender: TObject);
    begin
        if edit17.Text <>'' then 
         begin
         main_1.ListBox2.items.add(edit17.text);
         with adoquery1 do
           begin
           close;
           sql.clear;
           sql.add('insert into notes(note) values(:a)');
           parameters.parambyname('a').Value:=Trim(Edit17.Text);
           execsql;
           end;
     // showmessage('添加完成!');
         end
       else  
       messagedlg('请输入内容',MtError,[mbOK],0); 
    end;给分
      

  8.   

    楼上的还是提示 insert语法错误啊    我快疯了!
      

  9.   

    adoquery1.sql.add('insert into notes([note]) values('''+edit17.text+''')');
    把note用[]括起来
      

  10.   

    如果还有错误你把note字段名字换成其他的名字试试。
      

  11.   

    procedure Tmain_1.Button18Click(Sender: TObject);
    begin
        if edit17.Text <>'' then 
         begin
         main_1.ListBox2.items.add(edit17.text);
         with adoquery1 do
           begin
           close;
           sql.clear;
           sql.add('insert into notes([note]) values(:a)');//note添加[]之后问题解决了 
           parameters.parambyname('a').Value:=Trim(Edit17.Text);
           execsql;
           end;
     // showmessage('添加完成!');
         end
       else  
       messagedlg('请输入内容',MtError,[mbOK],0); 
    end;谢谢楼上的几位  太感谢了。。这几天没有你们的帮忙我的毕业设计就没这么快了  
    真的很感谢