Board index » delphi » SQL.Add('SELECT * FROM MyTableName')

SQL.Add('SELECT * FROM MyTableName')

When I  name a table at runtime and then use
SQL.Add('SELECT * FROM MyTableName')
i want to use something like this
 SQL.Add('SELECT * FROM Edit1.Text')
is that possible?

Regards
christer
christer.borgqv...@swipnet.se

 

Re:SQL.Add('SELECT * FROM MyTableName')


Quote
Christer Borgqvist wrote:
> When I  name a table at runtime and then use
> SQL.Add('SELECT * FROM MyTableName')
> i want to use something like this
>  SQL.Add('SELECT * FROM Edit1.Text')
> is that possible?

SQL.Add('SELECT * FROM ' + Edit1.Text) will work just fine.

HTH - Mike
--
==========================================
=  Michael D. Mount                      =
=  National Field Representatives, Inc.  =
=  Claremont, New Hampshire              =
==========================================

Re:SQL.Add('SELECT * FROM MyTableName')


Quote
>When I  name a table at runtime and then use
>SQL.Add('SELECT * FROM MyTableName')
>i want to use something like this
> SQL.Add('SELECT * FROM Edit1.Text')
>is that possible?

  Yes. Just do it the following way.

  1. Set the SQL property or your tquery : SELECT * FROM :MYTABLE
  2. Click on params and you will see MYTABLE inside. Select 'STRING' from
the combobox.
  3. At runtime, when you want to set the table you do the following:

        QUERY1.PARAMBYNAME('MYTABLE').ASSTRING:='CUSTOMERS';
        QUERY1.OPEN;

  or   QUERY1.PARAMBYNAME('MYTABLE').ASSTRING:='ORDERS';
        QUERY1.OPEN;

Devletoglou Vassilis,
Bull Corporation, Greece.

Re:SQL.Add('SELECT * FROM MyTableName')


Sql.Add('SELECT * FROM ' + Edit1.Text);

Bernd Maierhofer
dato Denkwerkzeuge
EDV-Projekte, Beratung, Softwareerstellung
Corneliusgasse 4
A-1060 Wien, Austria
Fax:  (43)(1)581 29 80
Mail: Ber...@dato.at

Re:SQL.Add('SELECT * FROM MyTableName')


Use SQL.Add('SELECT * FROM ' + Edit1.Text)

After '... FROM' put a blanck space inside string :'... FROM ' !

Other Threads