Link to home
Start Free TrialLog in
Avatar of QurbanDurrani
QurbanDurrani

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of rfwoolf
rfwoolf
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QurbanDurrani
QurbanDurrani

ASKER

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

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.