Board index » delphi » 3rd POST, Please someone Help

3rd POST, Please someone Help

delphi 3, dbase files, I am using transactions.  why can I post without
error after an insert but the commit causes an EDatabaseError - Data
Structure Corruption.  This only happens when I insert, not on edits!!

database1.starttransaction;
table1.insert;
table1.sskey := newvalue;
table1.namekey := '';
table2.insert;
table2.sskey := newvalue;
table2.namekey := '';
table1.post;
table2.post;
database1.commit;

I've tried restructuring the tables and this does nothing to fix the
problem.  I debuged through and see that DBIEndTran is returning error code
8451.

please anyone that can help explain why this happens!
Thanks,
Michael

 

Re:3rd POST, Please someone Help


I assume you are using cached updates?

Here is a function I use to save changes to all tables on a form. See the
difference between your code, is your trying to insert records within the
transaction. You should be able to just insert and edits records normally, and
then when you want to save all inserts and edits, you start the transaction and
commit them if possible.  There are some good articles in the Delphi Informant
magazine, which I believe you can find stuff from the on the web. The May,
June, and July issues have a 3 part series on using cached updates. I don't
know anything about transactions without using cached updates, so I hope you
are using cached updates...

----------------------------------------------------------------------
function TForm1.ApplyUpdates( Form: TForm ): Boolean;
var
  x: Integer;
begin
  Result := True;
  Session.Databases[0].StartTransaction;
  try
    for x:=0 to Form.ComponentCount-1 do begin
     // Search through and find any TTables
     if Form.Components[x] is TTable then begin
        // If found a table, make sure any changes have been posted.
        if (Form.Components[x] as TTable).State in [dsEdit,dsInsert] then
          (Form.Components[x] as TTable).Post;
        // If using cached updates....
        if (Form.Components[x] as TTable).CachedUpdates = True then
           // and if there are updates pending, apply them
           if (Form.Components[x] as TTable).UpdatesPending = True then
             (Form.Components[x] as TTable).ApplyUpdates;
      end;
    end;
    Session.DataBases[0].Commit;
  except
    Result := False;
    Session.Databases[0].RollBack;
  end;

  for x:=0 to Form.ComponentCount-1 do
    if Form.Components[x] is TTable then
      if (Form.Components[x] as TTable).CachedUpdates = True then
        if (Form.Components[x] as TTable).Active = True then
          (Form.Components[x] as TTable).CommitUpdates; // This is a bad name
for a

// function, since all it does is clear the cache.
end;
--------------------------------------------------------------------------------------

srdan...@hotmail.com
Daniel Raith

Quote
<Michael Messerschmidt wrote:
> delphi 3, dbase files, I am using transactions.  why can I post without
> error after an insert but the commit causes an EDatabaseError - Data
> Structure Corruption.  This only happens when I insert, not on edits!!

> database1.starttransaction;
> table1.insert;
> table1.sskey := newvalue;
> table1.namekey := '';
> table2.insert;
> table2.sskey := newvalue;
> table2.namekey := '';
> table1.post;
> table2.post;
> database1.commit;

> I've tried restructuring the tables and this does nothing to fix the
> problem.  I debuged through and see that DBIEndTran is returning error code
> 8451.

> please anyone that can help explain why this happens!
> Thanks,
> Michael

Re:3rd POST, Please someone Help


I assume you are using cached updates?

Here is a function I use to save changes to all tables on a form. See the
difference between your code, is your trying to insert records within the
transaction. You should be able to just insert and edits records normally, and
then when you want to save all inserts and edits, you start the transaction and
commit them if possible.  There are some good articles in the Delphi Informant
magazine, which I believe you can find stuff from the on the web. The May,
June, and July issues have a 3 part series on using cached updates. I don't
know anything about transactions without using cached updates, so I hope you
are using cached updates...

----------------------------------------------------------------------
function TForm1.ApplyUpdates( Form: TForm ): Boolean;
var
  x: Integer;
begin
  Result := True;
  Session.Databases[0].StartTransaction;
  try
    for x:=0 to Form.ComponentCount-1 do begin
     // Search through and find any TTables
     if Form.Components[x] is TTable then begin
        // If found a table, make sure any changes have been posted.
        if (Form.Components[x] as TTable).State in [dsEdit,dsInsert] then
          (Form.Components[x] as TTable).Post;
        // If using cached updates....
        if (Form.Components[x] as TTable).CachedUpdates = True then
           // and if there are updates pending, apply them
           if (Form.Components[x] as TTable).UpdatesPending = True then
             (Form.Components[x] as TTable).ApplyUpdates;
      end;
    end;
    Session.DataBases[0].Commit;
  except
    Result := False;
    Session.Databases[0].RollBack;
  end;

  for x:=0 to Form.ComponentCount-1 do
    if Form.Components[x] is TTable then
      if (Form.Components[x] as TTable).CachedUpdates = True then
        if (Form.Components[x] as TTable).Active = True then
          (Form.Components[x] as TTable).CommitUpdates; // This is a bad name
for a

// function, since all it does is clear the cache.
end;
--------------------------------------------------------------------------------------

srdan...@hotmail.com
Daniel Raith

Quote
<Michael Messerschmidt wrote:
> delphi 3, dbase files, I am using transactions.  why can I post without
> error after an insert but the commit causes an EDatabaseError - Data
> Structure Corruption.  This only happens when I insert, not on edits!!

> database1.starttransaction;
> table1.insert;
> table1.sskey := newvalue;
> table1.namekey := '';
> table2.insert;
> table2.sskey := newvalue;
> table2.namekey := '';
> table1.post;
> table2.post;
> database1.commit;

> I've tried restructuring the tables and this does nothing to fix the
> problem.  I debuged through and see that DBIEndTran is returning error code
> 8451.

> please anyone that can help explain why this happens!
> Thanks,
> Michael

Re:3rd POST, Please someone Help


I assume you are using cached updates?

Here is a function I use to save changes to all tables on a form. See the
difference between your code, is your trying to insert records within the
transaction. You should be able to just insert and edits records normally, and
then when you want to save all inserts and edits, you start the transaction and
commit them if possible.  There are some good articles in the Delphi Informant
magazine, which I believe you can find stuff from the on the web. The May,
June, and July issues have a 3 part series on using cached updates. I don't
know anything about transactions without using cached updates, so I hope you
are using cached updates...

----------------------------------------------------------------------
function TForm1.ApplyUpdates( Form: TForm ): Boolean;
var
  x: Integer;
begin
  Result := True;
  Session.Databases[0].StartTransaction;
  try
    for x:=0 to Form.ComponentCount-1 do begin
     // Search through and find any TTables
     if Form.Components[x] is TTable then begin
        // If found a table, make sure any changes have been posted.
        if (Form.Components[x] as TTable).State in [dsEdit,dsInsert] then
          (Form.Components[x] as TTable).Post;
        // If using cached updates....
        if (Form.Components[x] as TTable).CachedUpdates = True then
           // and if there are updates pending, apply them
           if (Form.Components[x] as TTable).UpdatesPending = True then
             (Form.Components[x] as TTable).ApplyUpdates;
      end;
    end;
    Session.DataBases[0].Commit;
  except
    Result := False;
    Session.Databases[0].RollBack;
  end;

  for x:=0 to Form.ComponentCount-1 do
    if Form.Components[x] is TTable then
      if (Form.Components[x] as TTable).CachedUpdates = True then
        if (Form.Components[x] as TTable).Active = True then
          (Form.Components[x] as TTable).CommitUpdates; // This is a bad name
for a

// function, since all it does is clear the cache.
end;
--------------------------------------------------------------------------------------

srdan...@hotmail.com
Daniel Raith

Quote
Michael Messerschmidt wrote:
> delphi 3, dbase files, I am using transactions.  why can I post without
> error after an insert but the commit causes an EDatabaseError - Data
> Structure Corruption.  This only happens when I insert, not on edits!!

> database1.starttransaction;
> table1.insert;
> table1.sskey := newvalue;
> table1.namekey := '';
> table2.insert;
> table2.sskey := newvalue;
> table2.namekey := '';
> table1.post;
> table2.post;
> database1.commit;

> I've tried restructuring the tables and this does nothing to fix the
> problem.  I debuged through and see that DBIEndTran is returning error code
> 8451.

> please anyone that can help explain why this happens!
> Thanks,
> Michael

Re:3rd POST, Please someone Help


Are you inserting into a table shared by other users on a network
containing Win95B machines?  If so, that COULD be your problem.

We've discovered that in Delphi 1 running BDE 2.52 that a Win95b machine
inserting records into a table (paradox) that is shared by other machines
will corrupt the table structure.

Re:3rd POST, Please someone Help


Daniel,

No, I am not.  Should I?

Quote
> I assume you are using cached updates?>

Michael

Re:3rd POST, Please someone Help


Scott,

how do I tell if my machine is a Win95B?  I am running this on a network;
however, I'm the only one running the program.
how do I tell the BDE version that I'm running?

thanks,
Michael

Quote
> Are you inserting into a table shared by other users on a network
> containing Win95B machines?  If so, that COULD be your problem.

> We've discovered that in Delphi 1 running BDE 2.52 that a Win95b machine
> inserting records into a table (paradox) that is shared by other machines
> will corrupt the table structure.

Re:3rd POST, Please someone Help


Michael Messerschmidt <rmess...@pheaa.org> wrote in article
<01bcf35f$a81c4940$14239ca4@anxpc01007>...

Quote
> Scott,

> how do I tell if my machine is a Win95B?  I am running this on a network;
> however, I'm the only one running the program.
> how do I tell the BDE version that I'm running?

You can pull up the properties on the "My Computer" icon on your desktop.
On the GENERAL tab, you should see the information under the header
"System:" which says:

[this taken from Win95a machine]
Microsoft Windows 95
4.00.950a       <-- here is where you can tell...

As for the version of the BDE you are running, I'm not entirely sure.  I
know what version I am running (v2.52) simply because I pulled it off of
the Borland web site.

If you are really the only one running [your application] on the network,
then I don't think that this is the problem, but I cannot be sure.

- Scott

Re:3rd POST, Please someone Help


Quote
Michael Messerschmidt wrote:

> Scott,

> how do I tell if my machine is a Win95B?  I am running this on a network;
> however, I'm the only one running the program.
> how do I tell the BDE version that I'm running?

> thanks,
> Michael

> > Are you inserting into a table shared by other users on a network
> > containing Win95B machines?  If so, that COULD be your problem.

> > We've discovered that in Delphi 1 running BDE 2.52 that a Win95b machine
> > inserting records into a table (paradox) that is shared by other machines
> > will corrupt the table structure.

Hi, Michael.  Scott told you how to find the Win95 version.  

For the BDE version I believe D2.01 shipped with BDE 3.0.  I d/l'ed BDE
3.5 from www.borland.com.  I am not sure if BDE4.0 shipped with D3 but
it seems so.

Regards, -= Lou Rizzuto =-

Re:3rd POST, Please someone Help


Michael Messerschmidt <rmess...@pheaa.org> wrote in article
<01bcf35f$a81c4940$14239ca4@anxpc01007>...

Quote
> Scott,

> how do I tell the BDE version that I'm running?

Check the TIME stamp of the idapi dll file in the BDe directory.

Connie

Re:3rd POST, Please someone Help


Scott,

No I am running Win95a.  From what I can tell it looks like I'm running BDE
2.52.  Any other ideas?

Michael

Re:3rd POST, Please someone Help


Michael

Quote
> how do I tell the BDE version that I'm running?

Look in the BDE directory.  The timestamp on the .DLL files is the version
that you're running.

Mike

Re:3rd POST, Please someone Help


Scott,

I don't have any Blobs or Memos in the files, just string and numeric data.

Michael

Scott Hamilton <Sco...@Sensory.Com> wrote in article
<01bcf8d3$be8e0e60$e6332299@hamilton>...

Quote
> Michael Messerschmidt <rmess...@pheaa.org> wrote in article
> <01bcf424$7edc5460$14239ca4@anxpc01007>...
> > Scott,

> > No I am running Win95a.  From what I can tell it looks like I'm running
> BDE
> > 2.52.  Any other ideas?

> Sorry this is so late -- was out of state.

> The only other reasons I have experienced that cause BLOB MODIFIED errors
> are:

> 1) application failure that shuts down the app unexpectedly, and
> 2) table corruption that does not show errors until the BLOB MODIFIED.

> If you have TUTILITY.DLL or the 32-bit version (look on the Borland web
> page under the BDE updates section) you might want to attempt to repair
the
> table(s) exhibiting this problem.  It could very well be a blob/memo file
> header issue or something.

Other Threads