I load a DBGrid with the first table in FormCreate. On a button click I create a NewData table and replace the contents of the DBGrid with this new table. All works well. When I close the program, the .sql file does not include this 2nd table. What do I need to do? Here's my code for creating that 2nd table.
SQLQuery1.SQL.Text := 'DROP TABLE IF EXISTS NewData';
SQLQuery1.ExecSQL;
SQL := 'CREATE TABLE NewData ([ID] INTEGER PRIMARY KEY';
SQL := SQL + ', tContract INT';
SQL := SQL + ', tResult INT';
SQL := SQL + ');';
SQLQuery1.SQL.Text := SQL;
SQLQuery1.ExecSQL;
SQL := 'CREATE INDEX AContract ON NewData (tcontract);';
SQLQuery1.SQL.Text := SQL;
SQLQuery1.ExecSQL;
with Datasource1.dataset do begin // from the first table
First;
i := 0;
while not EOF do begin
c := Cont2Num(Fields[1].AsString);
r := Fields[2].AsInteger; // result
SQL := 'INSERT INTO NewData VALUES(' + IntToStr(i) + ',' +
IntToStr(r) + ',' + IntToStr(c) + ');';
SQLQuery1.SQL.Text := SQL;
SQLQuery1.ExecSQL;
Inc(i);
Next;
end;// while
end; // with dataset
// now replace the DBGrid with this NewData
SQLQuery1.Close;
SQLQuery1.SQL.Text := 'select * from NewData';
SQLQuery1.Open;