我的插入代码
 total:=form3.ADOQuery1.RecordCount+1;  showmessage(inttostr(total));
 form3.ADOQuery1.Close;
 form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total,"aaa","bbb")';
 form3.ADOQuery1.ExecSQL;
我更新代码
  with form3.ADOQuery1 do
   begin
   Close;
   SQL.Clear;
   SQL.Add('update '+getyuyan+' set 内容='''+Memo1.Text+''' where 标题='+form3.ComboBox1.Text+'');
   ExecSQL;
   end;
什么地方错了?

解决方案 »

  1.   

    你把SQL的语句赋值给一个字符串变量,然后在调试看看你的字符串是什么样子,不就知道什么地方错了?
      

  2.   

    我的插入代码
     total:=form3.ADOQuery1.RecordCount+1;  showmessage(inttostr(total));
     form3.ADOQuery1.Close;
     form3.adoquery1.sql.clear;//notice ,you must clear the sql before new sql.
     form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total,"aaa","bbb")';
     form3.ADOQuery1.ExecSQL;
    我更新代码
      with form3.ADOQuery1 do
       begin
       Close;
       SQL.Clear;
       SQL.Add('update '+getyuyan+' set 内容='''+Memo1.Text+''' where 标题='+form3.ComboBox1.Text+'');
       ExecSQL;
       end;
    什么地方错了?
      

  3.   

    form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values(:total//这个地方有问题,"aaa","bbb")';
     参数赋值不是这样子的。
    你可以改一下你的语名
    form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values('''+total+''',"aaa","bbb")';
      

  4.   


    加引号的话最好是QuotedStr
      

  5.   

    插入代码
     total:=form3.ADOQuery1.RecordCount+1;  showmessage(inttostr(total));
     form3.ADOQuery1.Close;
     form3.ADOQuery1.SQL.Text:='insert into ['+getyuyan+'](ID,标题,内容) values('+#39+inttostr(total)+#39+','+#39+'aaa'+#39+','+#39+'bbb'+#39+')';
     form3.ADOQuery1.ExecSQL;
    更新代码
      with form3.ADOQuery1 do
       begin
       Close;
       SQL.Clear;
       SQL.Add('update '+getyuyan+' set 内容='+#39+Memo1.Text+#39+' where 标题='+#39+form3.ComboBox1.Text+#39);
       ExecSQL;
       end;
      

  6.   

    //*******************************************************************************
    我在http://www.pediy.com/tutorial/appen-a/append-A.htm查到#39是个',直接写为什么不可以呢?
    另外:我的数据库里total是int,为什么整形变量要inttostr(total)才能成功?
    //*******************************************************************************