Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 28th, 2004, 01:31 PM
spy007z spy007z is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 spy007z User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Cannot modify TADODataSet after open

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

Reply With Quote
  #2  
Old April 29th, 2008, 09:15 AM
fred10538 fred10538 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 fred10538 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 sec
Reputation Power: 0
Quote:
Originally Posted by spy007z
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';

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


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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Cannot modify TADODataSet after open


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT