Solved

create a Paradox5 table

Posted on 1998-09-18
9
234 Views
Last Modified: 2010-04-06
Hello.

I want to create a table of 'Paradox 5' type.
Because I want to import this Paradox-type table to MSAccsess
which does't seem to support Paradox7.

Now I create table by 'CreateTable'method. But this table type is
Paradox7. So I can't import it.
Can I create a Paradox5 type table?

Thanks for your help.


Syouchi
0
Comment
Question by:Syouchi
  • 7
  • 2
9 Comments
 
LVL 1

Expert Comment

by:nrobin
ID: 1340113
Syouchi,

Its all about creating a table with a different BDE level.

This list is from BDE.INT.

{ Table levels }

const
  TBLLEVEL3          = 3;               { Paradox level 3 and dBASE level 3+ }
  TBLLEVEL4          = 4;               { Paradox level 4 and dBASE level 4 }
  TBLLEVEL5          = 5;               { Paradox level 5 and dBASE/Win }
  TBLLEVEL7          = 7;               { Paradox level 7 , Win32 }
  FOXLEVEL25         = 25;              { Fox Table (Ver 2.5) }

So using this youcan use the dbiCreateTable function:


procedure fDbiCreateTable(hTmpDb: hDBIDb; TableName: String; Fields: Word;
             pFlds: pFLDDesc; Level, BlockSize, FillFactor: Word);
var
  pOptDesc, pOrigDesc: pFLDDesc;
  pOptData, pOrigData: pBYTE;
  TblDesc: CRTblDesc;
  sLevel, sBlockSize, sFillFactor: String;

begin
  pOptDesc := AllocMem(3 * sizeof(FLDDesc));
  pOrigDesc := pOptDesc;
  pOptData := AllocMem(20);
  pOrigData := pOptData;
  try
    sLevel := IntToStr(Level);
    sBlockSize := IntToStr(BlockSize);

    sFillFactor := IntToStr(FIllFactor);
    // Set up first parameter
    pOptDesc.iOffset := 0;
    pOptDesc.iLen := Length(sLevel) + 1;
    StrPCopy(pOptDesc.szName, 'LEVEL');
    StrPCopy(PChar(pOptData), sLevel);
    Inc(pOptData, Length(sLevel) + 1);
    Inc(pOptDesc);
    // Set up second parameter
    pOptDesc.iOffset := Length(sLevel) + 1;
    pOptDesc.iLen := Length(sLevel) + 1 + Length(sBlockSize) + 1;
    StrPCopy(pOptDesc.szName, 'BLOCK SIZE');
    StrPCopy(PChar(pOptData), sBLockSize);

    Inc(pOptData, Length(sBlockSize) + 1);
    Inc(pOptDesc);
    // Set up third parameter
    pOptDesc.iOffset := Length(sLevel) + 1 + Length(sBlockSize) + 1;
    pOptDesc.iLen := Length(sLevel) + 1 + Length(sBlockSize) + 1 + Length(sFillFactor) + 1;
    StrPCopy(pOptDesc.szName, 'FILL FACTOR');
    StrPCopy(PChar(pOptData), sFillFactor);
    // Format the table descriptor
    FillChar(TblDesc, sizeof(TblDesc), #0);
    StrPCopy(TblDesc.szTblName, TableName);
    StrCopy(TblDesc.szTblType, szPARADOX);

    TblDesc.iOptParams := 3;
    TblDesc.pFldOptParams := pOrigDesc;
    TblDesc.pOptData := pOrigData;
    TblDesc.iFldCount := Fields;
    TblDesc.pFldDesc := pFlds;
    // Create the table
    Check(DbiCreateTable(hTmpDb, True, TblDesc));
  finally
    FreeMem(pOrigDesc, 3 * sizeof(FLDDesc));
    FreeMem(pOrigData, 20);
  end;
end;

USAGE: fDbiCreateTable(Database1.Handle, 'TableChange', 3, @FDesc, 7, 32768, 95);

HTH

Nicholas.
0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340114
BTW, its not that easy! ;)
0
 

Author Comment

by:Syouchi
ID: 1340115
Hmmmm....

you are right.
It's not easy.... :(


Syouchi

0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 1

Expert Comment

by:nrobin
ID: 1340116
The bit you need is the FieldDefs, once you have that you should be ok.

Nicholas.
0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340117
Syouchi,

Ihave successfully created myself a table using the above with some field defs....I will put it up, but 50 points seems a little too small 8)

Nicholas.
0
 
LVL 1

Accepted Solution

by:
nrobin earned 100 total points
ID: 1340118
const
  DB_LEVEL_5 = 5; // Paradox 5 format

const
      FieldDescriptors: array [0..1] of
            FLDDesc = (
                                          (iFldNum:      1;            { Field Number }
                                           szName:       'FIELD1';     { Field Name }
                                           iFldType:     fldINT32;     { Field Type }
                                           iSubType:     fldUNKNOWN;   { Field Subtype }
                                           iUnits1:      0;            { Field Size }
                                           iUnits2:      0;            { Decimal places ( 0 ) }
                                           iOffset:      0;            { Offset in record ( 0 ) }
                                           iLen:         0;            { Length in Bytes  ( 0 ) }
                                           iNullOffset:  0;            { For Null Bits    ( 0 ) }
                                           efldvVchk:    fldvNOCHECKS; { Validiy checks   ( 0 ) }
                                           efldrRights:  fldrREADWRITE { Rights }
                                          ),
                                          (iFldNum:      2;
                                           szName:       'FIELD2';
                                           iFldType:     fldZSTRING;
                                           iSubType:     fldUNKNOWN;
                                           iUnits1:      254;
                                           iUnits2:      0;
                                           iOffset:      0;
                                           iLen:         0;
                                           iNullOffset:  0;
                                           efldvVchk:    fldvNOCHECKS;
                                           efldrRights:  fldrREADWRITE
                                          )
                                          );


procedure TForm1.Button1Click(Sender: TObject);
begin
  fDbiCreateTable (Database1.Handle, 'MyNewTable', 2,  
  @FieldDescriptors, DB_LEVEL_5, 32768, 95);
end;

Syouchi,

Cut and paste the original function previously into this, then create database component on a form.  Set its aliasname and databasename to the same - I created an alias and made them both the aliasname.  Then test it by creating setting active to true.

e.g.
 New Alias: dbi_test_alias
 database1.aliasname := 'dbi_test_alias';
 database1.databasename := 'dbi_test_alias';
 database1.active := true;

I set these up at design time but you could do it in the button1.click.

Then thats it.  The field defs define two fields FIELD1 as an integer, FIELD2 as a string.  Look in bde.int for definitions.

Hope this warrants better points ;)

Good luck Syouchi.

Regards

Nicholas.


0
 

Author Comment

by:Syouchi
ID: 1340119
Thanks a lot.

Your code is really excellent.
I will give you 100 points.
Is it enough?


Syouchi

0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340120
No probs Syouchi.  The message I received from Expert exchange says I earned "400 quality points"...think there must have been wires crosed ;)

Well done, glad its sorted.

Regards

Nicholas.
0
 
LVL 1

Expert Comment

by:nrobin
ID: 1340121
No need to reply, just realised what expert exchange meant..doh.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 90
LAN or WAN ? 11 91
control image tags in a string ? 12 131
How to create virtual printer while installing my application 5 50
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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