Solved

create a Paradox5 table

Posted on 1998-09-18
9
229 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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

22 Experts available now in Live!

Get 1:1 Help Now