|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Quote:
I found this old unanswered thread and I just can't resist to answer. The question I would pose to spy007z, is this: When you request a dataset post, do you really expect the dataset to "read" your complex case statement and work out for itself that you want the "checked" field to be updated? Solution: select both the case result field and the field itself in your select statement. ie. select checked = case blah blah as checkdisplay, checked from order. Use the checkdisplay in your grid, and update the checkedfield during edit/insert. Simple huh? I hope you figured this out yourself in the 4 years since you posted this message! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Cannot modify TADODataSet after open |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|