Create Pdx table at runtime

Create Pdx table at runtime

Post by Jose Luis Garcia de la Fuent » Sun, 31 Dec 1899 09:00:00



Hello.

I want to create a Pdx table at runtime. This is my code:

procedure TForm1.FormCreate(Sender: TObject);
begin
 IF NOT FileExists(ExtractFilePath(Application.ExeName)+'MYDB.DB') THEN
  begin
   MessageDlg('DB not found'+#10#10+'Creating new DB',
   mtInformation,[mbOK],0);
   with table1 do
   begin
    Active:= False;
    DatabaseName:= ExtractFilePath(Application.ExeName);
    TableName:= ExtractFilePath(Application.ExeName)+ 'MYDB.DB';
    TableType:= ttParadox;
   with FieldDefs do
    begin
     Clear;
     Add('City',ftString,10,True);
     Add('Adress',ftString,40,False);
     Add('Name',ftString,20,False);
   (* Add('Telephone',ftInteger,8,False); *)
    end;
   with IndexDefs do
    begin
     Clear;
     Add('Ascending','city',[ixPrimary,ixunique]);
    end;
   CreateTable;
   end;
  end;
end;

It works, if I remove the line:  Add('Telephone',ftInteger,8,False);
If  I dont remove that line, I get the error:
"Project Project1.exe raised exception class EDatabaseError with message
'Invalid field size'"

Why ???

Help me please!

Thanks a lot!!

 
 
 

Create Pdx table at runtime

Post by Jeremy Collin » Sun, 31 Dec 1899 09:00:00


{snip}

Quote:>   with FieldDefs do
>    begin
>     Clear;
>     Add('City',ftString,10,True);
>     Add('Adress',ftString,40,False);
>     Add('Name',ftString,20,False);
>   (* Add('Telephone',ftInteger,8,False); *)
>    end;
>   with IndexDefs do
>    begin
>     Clear;
>     Add('Ascending','city',[ixPrimary,ixunique]);
>    end;
>   CreateTable;
>   end;
>  end;
>end;

>It works, if I remove the line:  Add('Telephone',ftInteger,8,False);
>If  I dont remove that line, I get the error:
>"Project Project1.exe raised exception class EDatabaseError with message
>'Invalid field size'"

You should specify 0 (zero) instead of 8 for the field size. This
isn't obvious - I guess that the BDE sorts out the size of an integer
on the target platform internally to allow 16 and 32 bit compatibility.

   ==>  Add('Telephone', ftInteger, 0, False);

HTH
--
Jeremy Collins

 
 
 

Create Pdx table at runtime

Post by Jason Wallac » Sun, 31 Dec 1899 09:00:00


  Because obviously, the 'Telephone' field is an 'invalid size'.   --
Change the 8 to a 0 (ps.  it's better to use a string with a mask  --  And
that CAN be limited in size...), and it'll work fine...  (an integer field
is a set field.  --   ie.  You can't limit the size of it...  You'd have to
do that in code...)

--
Jason Wallace
SL Software
DarkElf+AEA-SLSoftware.reno.nv.us
--
+ACI-We are Microsoft.  Resistance is Futile.  You will be Assimiliated.+ACI-


+ADw-353E0F3B.B2E2AC66+AEA-teleline.es+AD4-...
    Hello.
    I want to create a Pdx table at runtime. This is my code:

    procedure TForm1.FormCreate(Sender: TObject)+ADs-
    begin

       (+ACo- Add('Telephone',ftInteger,8,False)+ADs- +ACo-)

    It works, if I remove the line:  Add('Telephone',ftInteger,8,False)+ADs-  If
I don+ALQ-t remove that line, I get the error:
    +ACI-Project Project1.exe raised exception class EDatabaseError with message
'Invalid field size'+ACI-

    Why ???

 
 
 

1. Create Pdx table with password at runtime ????

Hi,

Can anybody help me figure out how to create a Paradox table with
a password from Delphi 3.0 Client Server at runtime?

Or even change a password on an existing Paradox table at runtime?

Many thanks in advance if you can help me out!

regards
Mike.

PS Please email me at....   mike at barf.com  
   (Ignore the email address above)

2. Quick question on changing IndexNames on Paradox tables with CachedUpdates.

3. PDX 7.0 Runtime and WinNT 3.51: Loockup-Function cause General Protection Violation

4. SQL DB Postal / Zip codes for america

5. WTB: Pdx Runtime versions 3, 5

6. about param "tcp on delay"

7. Q: Pdx-Runtime 7.0: other Splash-Screen

8. Dbase

9. Pdx 10 Runtime

10. Need a stand alone Tutility for Pdx 7 Runtime

11. I am looking for JAVA runtime PDX 8

12. Creating and restructure tables at runtime

13. Creating Specific Paradox Version Tables at Runtime