I am creating a table during runtime. This is how I do it:
AdoCommand1.Connection:=AdoConnection1;
cs:='CREATE TABLE '+edname.text+' (' +
'ID Integer IDENTITY(1,1) NOT NULL UNIQUE PRIMARY KEY,' +
'[Date Added] DATETIME,'+
'[Name] TEXT(255))';
ADOCommand1.CommandText:=cs;
ADOCommand1.Execute;
I need to add a field "age" which should be calculated automatically like this:
age = DateDiff ('y',[Date Added], Now())
, Which simply gives amount in days that item is stored. How do I do this at runtime? Is there a way to add dynamically calculated fields to Access Database?
Note: I use Delphi 7, ADO components and Microsoft Jet 4.0 to connect to MDB Database.