Board index » delphi » restructuring a paradox table on user's machine

restructuring a paradox table on user's machine

I'm getting ready to distribute an enhancement to a little application
that requires one of the paradox tables to be restructured (switching a
field from shortint to alpha).  My users already have data in their
files so I don't want to just copy the new file structure over their
existing database.  I can use db desktop on my machine to restructure
the table with no problem.  However, dbd32.exe isn't on their machines
(I used the installshield that came with D2 to distribute the app with
the default complete bde distribution).

Can I stick dbd32.exe on a diskette and restructure the table for them
or do I need the entire contents of the desktop directory?  Is there
some alternate way to restructure the table?

Thanks,
================================================
Ray Porter
Applications Analyst Programmer
Administrative Information Services, UNC-CH
Phone: 966-5878
email: l...@email.adp.unc.edu
         dra...@email.unc.edu
Home Page: http://www.adp.unc.edu/~lrp/

"Meddle not in the affairs of dragons,
for you are crunchy and taste good with ketchup."

 

Re:restructuring a paradox table on user's machine


Quote
Ray Porter wrote:

> I'm getting ready to distribute an enhancement to a little application
> that requires one of the paradox tables to be restructured (switching a
> field from shortint to alpha).  My users already have data in their
> files so I don't want to just copy the new file structure over their
> existing database.  I can use db desktop on my machine to restructure
> the table with no problem.  However, dbd32.exe isn't on their machines
> (I used the installshield that came with D2 to distribute the app with
> the default complete bde distribution).

> Can I stick dbd32.exe on a diskette and restructure the table for them
> or do I need the entire contents of the desktop directory?  Is there
> some alternate way to restructure the table?

You could try this kind of procedure (tested in D1) to create new
fields afterwards to Paradox tables. Just add some loops around to
have all your new fields added. You'll also have to develope the code
to copy the existing data to these new type fields.
A good practice to update databases to several customers is to compile
this kind of code to a stand alone program, UPDATE.EXE and send it to
customer. Because it does not need Forms or other interface stuff,
the size of EXE will be only 250 kB.

procedure AddFieldsWithQuery(aPath, aTablename, aFieldName, aFieldType :
string);
Var
Query : TQuery;
aTable : TTable;
S:String;
i:Integer;
begin
  aPath:=AddBackSlash(aPath); {Add backslash '\' to be safe}
  aTableName:=aPath + aTableName;
  aTable:=TTable.Create(nil);
  Query:=TQuery.Create(nil);
  aTable.TableName:=aTableName;
  aTable.Open;
  i:=aTable.FieldDefs.Indexof(aFieldName);
  aTable.Close;
  if i = -1 then
  try
    begin
      with query do begin
        with sql do begin
          clear;
          Add('ALTER TABLE "'+aTableName +'" ADD ' +aFieldName +' '
+aFieldType);
        end;
        ExecSQL;
      end;
    end;
  finally
    Query.Free;
    aTable.Free;
  end; {of Try..}
end;

program Update; { DataBase update }
uses
  DBTables;
begin
{This line of code adds a new datafield 'ShipToCity' (Character, length
15,)
 to ORDERS.DB}
   AddFieldsWithQuery('C:\DATA\', 'ORDERS.DB', 'ShipToCity', 'CHAR
(15)');
end.

Markku Nevalainen

Other Threads