Cannot modify TADODataset read-only field after open

From: spy007z (spy007z_at_aew_nospam.com)
Date: 10/28/04

  • Next message: Arthur: "Cannot modify TADODataSet after open"
    Date: 28 Oct 2004 11:16:56 -0700
    
    

    Hi, I user Delphi 6 and open my dataset with the following code:

        sSql := 'Select Checked=
                      Case (OverrideStatus) When 0
                              then (Case State When 4 then 1 else 0 end)
                            When 1 then 1
                              When 2 then 0
                            else 0 end
                 FROM ORDER';

        FADOConnection.BeginTrans;
        with ADODataSet do begin
          Close;
          ADODataSet.Connection := FADOConnection;
          CursorLocation := clUseClient;
          CursorType := ctStatic;
          LockType := ltBatchOptimistic;
          CommandType := cmdText;
          CommandText := sSql;
          Open;
        end;
        FADOConnection.CommitTrans;

    then I try to modify the dataset and found that the Checked field is readonly so I do the following:

      for iLoop := 0 to FDataSet.Fields.Count - 1 do
        ADODataSet.Fields[iLoop].ReadOnly := False;

      for iLoop := 0 to FDataSet.FieldDefs.Count - 1 do
        ADODataSet.FieldDefs[iLoop].Attributes := ADODataSet.FieldDefs[iLoop].Attributes - [faReadOnly];

      ADODataSet.First;
      ADODataSet.Edit;
      ADODataSet.Fields[0].AsInteger := 0;
      ADODataSet.Post;

    When in debug mode, I watch the Fields[0].AsInterger and the value get modifed after the line

      ADODataSet.Fields[0].AsInteger := 0;

    however after ADODataSet.Post is ran, the value of Fields[0].AsInterger set back to it's orignal value.

    Can anyone help me with this problem... TIA

    User submitted from AEWNET (http://www.aewnet.com/)


  • Next message: Arthur: "Cannot modify TADODataSet after open"