Creating a paradox table using ADO

I want to create a paradox table at run time, using an TABOQuery. The Table is copied from an MSAccess table.

I get the error "Syntax error in query: Incomplete query clause" from this SQL

ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT Mileage.UnitID, Mileage.Date, Mileage.Time,');
    ADOQuery1.SQL.Add('       Mileage.CalcMile, Mileage.Mileage');
    ADOQuery1.SQL.Add('INTO '''+ExtractFileName(sTargetPath)+'''');
    ADOQuery1.SQL.Add('IN '''+ExtractFilePath(sTargetPath)+'''');
    ADOQuery1.SQL.Add('FROM Mileage;');
    ADOQuery1.Open;


Thanks in advance,
                      Rick.
RickscottAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheNeilCommented:
Rick,

Try this out. It's a mod of some other code but according to the Delphi help it should work fine on files as well as aliases.

function CreateTableFrom(Source,SourceTable,Dest,DestTable : String) : Boolean;
var t : TTable;
begin
  Result := False;
  t := TTable.Create(Application);
  try
    try
      T.DatabaseName := Source;
      T.TableName := SourceTable;
      T.FieldDefs.Update;
      T.IndexDefs.Update;
      T.DatabaseName := Dest;
      T.TableName := DestTable;
      T.CreateTable;
      Result := True;
    except
      //errorhandling
    end;
  finally
    t.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  If CreateTableFrom('c:\db1.pdx','Memo_db.db','c:\db2.pdx','EmptyMemo_db.db') then
    Showmessage('Success')
  else
    Showmessage('Failure');
end;

The Neil
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RickscottAuthor Commented:
Cheers,

I would have like the SQL to work, but your approach did the job.
0
kretzschmarCommented:
nice :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.