[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

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.
0
Rickscott
Asked:
Rickscott
1 Solution
 
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
 
RickscottAuthor Commented:
Cheers,

I would have like the SQL to work, but your approach did the job.
0
 
kretzschmarCommented:
nice :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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