Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ParamByName

Posted on 2001-07-08
2
Medium Priority
?
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 150 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

705 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