Solved

ParamByName

Posted on 2001-07-08
2
562 Views
Last Modified: 2008-02-01
Why does this use of ParaByName give me an generel SQL error.
QryLocal.Close;
QryLocal.SQL.Text := 'SELECT * FROM :TABLENAME';
QryLocal.ParamByName('TABLENAME').AsString := 'TEST';
QryLocal.Open;

when this works fine
QryLocal.Close;
QryLocal.SQL.Text := 'SELECT * FROM TEST';
QryLocal.Open;
0
Comment
Question by:glx2k
2 Comments
 
LVL 3

Expert Comment

by:MarcG
ID: 6262922
I only use Params if I have a fixed SQL.text ( I set it in the graphical query component), and after entering the sql.text with param you have to set the right param type with clicking on params in explorer.
Never tried with runtime queries but might be you have to set the param type there too.
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6262972
Hello

  ParamByName is used for fields name not for table names
  if you want to access to table name directly (not from alias", put the table in the double qutoation as following

QryLocal.Close;
QryLocal.SQL.Text := 'SELECT * FROM "Test.db"';
QryLocal.Open;

or if you want to access table in found in variable use the following code

var
  S : String;
begin
  QryLocal.Close;
  S := 'Test.db';
  QryLocal.SQL.Text := 'select * from '+ S;
  QryLocal.open;
end;

Best regards
Mohammed Nasman
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question