| |

VerySource

 Forgot password?
 Register
Search
View: 5|Reply: 1

How to create table names dynamically?

[Copy link]

2

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-3-21 08:00:02
| Show all posts |Read mode
This is wrong, how can I solve it? Thank you
procedure TForm3.Button2Click (Sender: TObject);
var
  tablename: string;
begin
    tablename: = formatdatetime ('yyyymd', strtodatetime (daystr));
    with ADOquery2 do
    begin
       close;
       sql.Clear;
       sql.Add ('select book number, sales quantity, sales unit price into' + tablename + 'from bookout');
       sql.Add ('where sales date =' + quotedstr (daystr));
Reply

Use magic Report

0

Threads

10

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

Post time: 4 day(s) ago
| Show all posts
sql.Add('exec(select book number, sales quantity, sales unit price into'+tablename+' from bookout');
sql.Add('where sales date='''+quotedstr(daystr))+''')';


Your date, I quoted it for you, should be needed.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list