Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dbase ttable won't update 1

Status
Not open for further replies.

CentauriAudio

Programmer
Apr 4, 2004
7
AU
Hi all - first post here and relatively new to Delphi...

Problem I have is:

Using BDE with TTable & TDataSource components linked to dBase file in Delphi6. I am reading in field data from a particular record to an array of edit boxes using

For i:= 0 to 26 do
CustEdit.Text:=DataModule1.TableCust.Fields.DisplayText;

which works well. I am setting this up so that when the user performs an edit, nothing gets written back to the table until the completed record edit is verified by an ok button. To write this I am using

DataModule1.TableCust.Edit;
For c:= 1 to 26 do
begin
DataModule1.TableCust.Fields[c].Value:= CustEdit[c].Text;
end;
DataModule1.TableCust.Post;

however the data is not being written to the database. The various readonly properties are set to false, and no runtime error is generated. Anyone got any ideas ?

I also note that TTable should have a State property, but one does not exist. Could this be something to do with dBase files? Would Paradox files be better?

Thanks in anticipation
 
Your code looks valid to me, may be someone else can spot a flaw.

TTable does have a state property, but it is public, not published. This means it is accessible in the program, but not the object inspector. Code like:

Edit1.Text:=IntToStr(integer(TableCust.State));

or

uses TypInfo;

Edit1.Text:=GetEnumName(TypeInfo(TDataSetState),integer(TableCust.State));

Monitoring TableCust.State seems a good diagnostic.

There is nothing fundamentally wrong with using dbase tables. Switching to Paradox will not help you. Unless, of course, you happen to have some setting wrong on the dbase access.

Good luck
Simon
 
try

DataModule1.TableCust.Edit;
For c:= 0 to 26 do DataModule1.TableCust.Fields[c].AsString := CustEdit[c].Text;
DataModule1.TableCust.Post;


Aaron Taylor
John Mutch Electronics
 
Ahh! - found the problem. It wasn't anything to do with the update routine at all.

I had a routine triggered from the datasource datachange which filled my memo box array with the table data. When the save routine called TableCust.edit, a datachange was triggered which immediately overwrote any changed memoboxes, so the original data was saved back to the table. The fix was to suppress the triggered update whilst writing the data. Interesting....

Thanks to Simon and Aaron for your replies.

Cheers
Graeme
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top