Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

corrupt Paradox DB

From Delphi 3.0I write to and read from Paradox db's (make with Database Desktop).
Frequently I get corrupted Paradox db's.
'Blob has changed' or even Delphi will crash when loading the program which has
a Paradox table inside.

This is how I manipulate the DB.

Emptying the DB:
 while not(HTML.EOF) do  begin  HTML.First; HTML.Edit; HTML.Delete; HTML.Next;end;
 HTML.First; HTML.Edit; HTML.Delete

Writing a record:
HTML.Edit;  HTML.Insert;  HTML.FieldByName('ORG').AsString :=  Complete;

I would like to know the possible reasons for this reoccurring errors and how to
minimize the change of getting them.

Thanks,
0
miauw
Asked:
miauw
  • 8
  • 4
  • 2
  • +2
1 Solution
 
ronit051397Commented:
- To delete the entire table use EmptyTable.
- After editing or inserting a record you must call Post, Did you?
- Do you manage to inser or edit a blob field?
0
 
miauwAuthor Commented:
Regarding EmptyTable
-> see the other question I have asked and you commented to
    it is about using EmptyTable which does not work.

Calling Post:
Yes (although my Delphi book say this isn't strictly necessary).

-Insert or editing blob's:
Yes ,this works fine.
0
 
ronit051397Commented:
Did you delete the pdoxusrs.net?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ZifNabCommented:
Hi miauw!

What about this, it's easy and I think it helps you a little further :

I see, that you frequently empty your tables, so I presume that you only use these tables when your program is active (i.e. the tables are filled when program is active and emptied when program is closed?). If this is the case, why don't you just create your paradox in the beginning of the application?

Here is a code snippet of how to create a table at run time from the Delphi Corner:

 How to Create a Table at Runtime

I was a VB programmer, until my recent shift to Delphi 2.0. How can I create a database in code?

It depends on the type of database you want to build. However, I can show you how to do it with a Paradox table. Conceivably, it stands to reason that since the
TTable is database-independent and if you've got the right settings in the BDE, you should be able to create a table with the TTable component in any database. This
is not necessarily true. SQL tables are normally created using the SQL call CREATE TABLE. And each server has its own conventions for creating tables and defining
fields. So it's important to note this if you're working with a SQL database. The problem is that SQL databases support different data types that aren't necessarily
available in the standard BDE set. For instance, MS SQL server's NUMERIC data format is not necessarily a FLOAT as it's defined in the BDE. So your best bet would
probably be to create SQL tables using SQL calls.

What you have to do is declare a TTable variable, create an instance, then with the TTable's FieldDefs property, add field definitions. Finally, you'll make a call to
CreateTable, and your table will be created. Here's some example code:

{ "Add" is the operative function here.
  Add(const Name: string; DataType: TFieldType; Size: Word; Required: Boolean);
}
procedure CreateATable(DBName,            //Alias or path
                       TblName : String); //Table Name to Create
var
  tbl : TTable;
begin
  tbl := TTable.Create(Application);
  with tbl do begin
    Active := False;
    DatabaseName := DBName;
    TableName := TblName;
    TableType := ttParadox;
    with FieldDefs do begin
      Clear;
      Add('LastName', ftString, 30, False);
      Add('FirstName', ftString, 30, False);
      Add('Address1', ftString, 40, False);
      Add('Address2', ftString, 40, False);
      Add('City', ftString, 30, False);
      Add('ST', ftString, 2, False);
      Add('Zip', ftString, 10, False);
    end;

    {Add a Primary Key to the table}
    with IndexDefs do begin
      Clear;
      Add('Field1Index', 'LastName;FirstName', [ixPrimary, ixUnique]);
    end;
   
    CreateTable; {Make the table}
  end;
end;

The procedure above makes a simple contact table, first by defining the fields to be included in the table, then creating a primary key. As you can see, it's a pretty
straightforward procedure. One thing you can do is to change the TableType property setting to a variable that's passed as a parameter to the procedure so you can
create DBase or even ASCII tables. Here's snippet of how you'd accomplish that:

procedure CreateATable(DBName,                //Alias or path
                       TblName : String);     //Table Name to Create
                       TblType : TTableType); //ttDefault, ttParadox, ttDBase, ttASCII
var
  tbl : TTable;
begin
  tbl := TTable.Create(Application);
  with tbl do begin
    Active := False;
    DatabaseName := DBName;
    TableName := TblName;
    TableType := TblType;
    with FieldDefs do begin
      Clear;
      Add('LastName', ftString, 30, False);
      Add('FirstName', ftString, 30, False);
      Add('Address1', ftString, 40, False);
      Add('Address2', ftString, 40, False);
      Add('City', ftString, 30, False);
      Add('ST', ftString, 2, False);
      Add('Zip', ftString, 10, False);
    end;

    {Add a Primary Key to the table}
    with IndexDefs do begin
      Clear;
      Add('Field1Index', 'LastName;FirstName', [ixPrimary, ixUnique]);
    end;
   
    CreateTable; {Make the table}
  end;
end;

Pretty simple, right? One thing you should note is that the TableType property is only used for desktop databases. It doesn't apply to SQL tables.

Oh well, that's it in a nutshell. Have fun!

Copyright ) 1995, 1996, 1997 Brendan V. Delumpa All Rights Reserved

Regards, ZiF.

If this is not the case, just give some more details.

0
 
ZifNabCommented:
Hi, forgot to tell you something, if you close your program you should also delete this table.... with table1.DeleteTable.

Regards, ZiF.

Maybe this can be also a solution to your other question : ...EmptyTable...
0
 
miauwAuthor Commented:
Thanks for you contribution ZifNab,
this will be useful to me in the future, but the data must remain in the DB after
Delphi/the program stops.

0
 
MarciusCommented:
I have not had the same problem, but have had problems with Paradox in the past. Firstly, I think that you should Post all the data changes after you have made them, it is good practice, even if you book says that it is not necessary.

Next thing to try, Paradox doesn't always make save the changes to disk, even after the Post method is called. One solution to this is to add dbiSaveChanges to you on Post event handler. This procedure is in the dbiProcs unit, so you will need to include that. This will ensure that all data changes are entered and safely on disk.

See if that makes any difference.
0
 
miauwAuthor Commented:
Thanks for the information.
I noticed that whenever I run the program outside the Delphi environment,
I do not get any problems. Probably the crashing or stopping of the
program running from Delphi is my problem.
When I use POST I just get more errors in the Delphi env, and in any
case, using POST or not,  it runs OK outside Delphi.
When I copy a previously saved DB to the one I will use, the problems (for that
moment) are gone too.
I just hate the fact that the Delphi debugger is not fully 'transparent'.



0
 
miauwAuthor Commented:
ZifNab, if you agree with my comment,
submit your previous comment as a answer and I will give you the points.
0
 
ZifNabCommented:
Hi miauw,
one question : do you exception messages? Maybe try this (so we may fully understand the problem) : uncheck the show exceptions messages and run again in D.
Regards, Tom.

0
 
miauwAuthor Commented:
Hi ZifNab, I do get the errors anymore...is this just a case of luck,
or was I writting to a corrupt part of my HD before?. As soon as the errors reoccurrer,
I will uncheck the show exceptions messages and report. Thank you.
0
 
miauwAuthor Commented:
I ment: I do not get the errors anymore
0
 
hrizalCommented:
Hi again miauw ...
have you finish with the 'unfriendly' error ?

Lets I try to see your code, i will try to find and explaining in here, about thats error.

Regard.

Point Hunter.
0
 
miauwAuthor Commented:
Thanks everyone.
So Hrizal, but previously, I wrote

> ZifNab, if you agree with my comment,  submit your previous comment as a answer and I will give you the points.

and as I did not get the error anymore, I ask ZifNab again: submit your
comment as a answer, otherwise I delete this quesion.

0
 
ZifNabCommented:
Hi miauw,
       one question : do you exception messages? Maybe try this (so we may fully understand the problem) : uncheck the show exceptions messages
       and run again in D.
       Regards, Tom.
0
 
miauwAuthor Commented:
Thanks ZifNab,

I am aware of this option. I did not uncheck it before.
I think Unchecking this, will lead to the same result as running
the EXE from the explorer:  no problem.
 
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now