Link to home
Start Free TrialLog in
Avatar of sal1150
sal1150

asked on

table name as paratmeter at runtmie

I have tquery its sqlstring is:
         sql:='select id,q,a,r1,r2,r3,level,rand(200) as id2 from quiz order by id2';

How can I put table name in parameter so when I open it again it will use sql string exept change of name of tabe?
example:
   tQuery1.SQL.Clear
   tQuery1.SQL.add('select id,q,a,r1,r2,r3,level,rand(200) as id2 from MYTABLE order by id2')
   tquery1.ParamByName('MYTABLE').AsString :=OpenDialog1.FileName;
  Tquery.open;
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KyleyHarris
KyleyHarris

I wont waste time answering when there are 3 valid answers, but I reccomend bpana as the cleanest solution for its ability to be scaled or modified more easily by replacing content of the function is much nicer than 'just' using a constant string....

Can we please close this so I stop seeing it as open. There are 3 good answers here.
Well there are three valid answers provided. Let him choose one or split the points. Maybe give the points to the first answer, in this case Kretszmar. It looks like he needs the points :) (Just kidding about that.) But again either split or first answer.