Solved

corrupt Paradox DB

Posted on 1998-05-28
16
261 Views
Last Modified: 2010-04-06
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
Comment
Question by:miauw
  • 8
  • 4
  • 2
  • +2
16 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1348296
- 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
 

Author Comment

by:miauw
ID: 1348297
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
 
LVL 5

Expert Comment

by:ronit051397
ID: 1348298
Did you delete the pdoxusrs.net?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1348299
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
 
LVL 8

Expert Comment

by:ZifNab
ID: 1348300
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
 

Author Comment

by:miauw
ID: 1348301
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
 
LVL 1

Expert Comment

by:Marcius
ID: 1348302
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
 

Author Comment

by:miauw
ID: 1348303
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:miauw
ID: 1348304
ZifNab, if you agree with my comment,
submit your previous comment as a answer and I will give you the points.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1348305
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
 

Author Comment

by:miauw
ID: 1348306
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
 

Author Comment

by:miauw
ID: 1348307
I ment: I do not get the errors anymore
0
 
LVL 2

Expert Comment

by:hrizal
ID: 1348308
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
 

Author Comment

by:miauw
ID: 1348309
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
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1348310
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
 

Author Comment

by:miauw
ID: 1348311
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now