• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

Trying to add a memo field to a paradox table at runtime.

Hi Experts,
I have attached the function call and the function itself. The code works fine when adding an Alpha or integer column, but it errors out when adding a memo field. I am probably not calling the function correctly. Wonder whats wrong with it.
//This function call works just fine
if  DFieldExists('TABS_Coll_IP','CONFIG','port') = false then
   begin
    DAddField('TABS_Coll_IP CHAR(15)', 'CONFIG', 'port');
    porttablechg := TRUE;
   end;
 
//This function call errors out
if  DFieldExists('Derived_Relation_Raw','CONFIG','point') = false then
   begin
    DAddField('TABS_Coll_IP Memo', 'CONFIG', 'point');
    pointtablechg := TRUE;
   end;
 
//This is the function being called
Function DAddField(flddef, dbName,tblName: String): Boolean;
var q : TQuery;
 
begin
       q := TQuery.Create(nil);
       try
       q.DatabaseName := dbName;
       q.Sql.Add('ALTER TABLE ' + tblName );
       q.sql.add(' ADD COLUMN ' + fldDef );
 
       q.ExecSQL;
 
       finally
       q.free;
       end;
end;

Open in new window

0
QurbanDurrani
Asked:
QurbanDurrani
  • 2
1 Solution
 
rfwoolfCommented:
If you are using the BDE then I believe you need to call the dbiDoRestructure or something function using the BDE - you should come right by searchng for similar questions on ee such as "paradox add field" or "paradox rename field" or "paradox delete field" etc
0
 
QurbanDurraniAuthor Commented:
Thanks rfwoolf for your response.
I actually figured it out with the help of a friend of mine. You deserve the points for at least trying. I'll attach the corrected code. I actually had to replace the word 'Memo' with 'BLOB' in the call to the function.

//corrected function call
if  DFieldExists('Derived_Relation_Raw','CONFIG','point') = false then
   begin
    DAddField('Derived_Relation_Raw BLOB', 'CONFIG', 'point');
    pointtablechg := TRUE;
   end;

Open in new window

0
 
rfwoolfCommented:
That's very kind of you QurbanDurrani.
I recall a whle back I did manage to make certain changes using SQL, but other changes like renaming a field I think  had to use the BDE's routines like dbiDorestructure.
 
I have since migrated to Firebird (recently actually) which was a very gruelling process because my entire application was strongly bound to paradox and firebird had all kinds of data idiosynchrisys but in the end I think it was worth it.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now