procedure TQCReplyForm.UpdateData;
我在ADOQuery1的屬性SQL裡寫上了update datatable set ...語句,我想在下面代碼執行時加上sql語句,怎麼加啊?begin
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    Parameters.ParamByName('Param1').Value:=Memo1.Lines.Text;
    Parameters.ParamByName('Param2').Value:=GetBoolean(CheckBox1);
    Parameters.ParamByName('Param3').Value:=Edit1.Text;
    Parameters.ParamByName('Param4').Value:=GetBoolean(CheckBox2);
    Parameters.ParamByName('Param5').Value:=Edit2.Text;
    Parameters.ParamByName('Param6').Value:=GetBoolean(CheckBox3);
    Parameters.ParamByName('Param7').Value:=Edit1.Text;
    Parameters.ParamByName('Param8').Value:=managementno;
    ExecSQL;
  end;
end;

解决方案 »

  1.   

    with ADOQuery1 do 
      begin
        Close;
        SQL.Clear;
        Sql.add('update ... ...');
        Parameters.ParamByName('Param1').Value:=Memo1.Lines.Text;
        ..
        ..
        ExecSQL;
      end;
    end;
      

  2.   

    我知道有種是直接加的:
    SQL.Add('insert into EmployeeData values(:a,:b,:c,:d,:e,:f,:g,:h,:i)');
    但上面那種我就不清楚了。
      

  3.   

    不是的,我的語句已在這裡寫好:object QCReplyForm: TQCReplyForm
    ....
      object Memo1: TMemo
        Left = 16
        Top = 216
        Width = 743
        Height = 169
        TabOrder = 9
      end
      object ADOQuery1: TADOQuery
        Connection = DataModule1.ADOConnection1
        Parameters = <
          item
            Name = 'Param1'
            Attributes = [paNullable]
            DataType = ftString
            NumericScale = 255
            Precision = 255
            Size = 500
          end
          item
            Name = 'Param2'
            Attributes = [paNullable]
            DataType = ftBoolean
            NumericScale = 255
            Precision = 255
            Size = 2
          end
          item
            Name = 'Param3'
            Attributes = [paNullable]
            DataType = ftString
            NumericScale = 255
            Precision = 255
            Size = 50
          end
          item
            Name = 'Param4'
            Attributes = [paNullable]
            DataType = ftBoolean
            NumericScale = 255
            Precision = 255
            Size = 2
          end
          item
            Name = 'Param5'
            Attributes = [paNullable]
            DataType = ftString
            NumericScale = 255
            Precision = 255
            Size = 50
          end
          item
            Name = 'Param6'
            Attributes = [paNullable]
            DataType = ftBoolean
            NumericScale = 255
            Precision = 255
            Size = 2
          end
          item
            Name = 'Param7'
            Attributes = [paNullable]
            DataType = ftString
            NumericScale = 255
            Precision = 255
            Size = 50
          end
          item
            Name = 'Param8'
            DataType = ftString
            NumericScale = 255
            Precision = 255
            Size = 20
          end>
        SQL.Strings = (
          'update complainNote '
          'set '
          
            ' TreatmentDescription=?,ToQCComplainReportYesOrNo=?,QCComplainRe' +
            'portNO=?,ToBadNoteYesOrNo=?,BadNoteNO=?,ToFMEAYesOrNo=?,FMEANO=?'
          'where ManagementID=?')
        Left = 392
        Top = 408
      end
    end
      

  4.   

    你为什么要在属性里写好了呢。
    就用 gxgyj(杰克.逊)不是很好吗。
    不懂你就弄懂呗。
    SQL.Clear;
    你在SQL里写什么有了这个语句也清空了。clear了。