Solved

ParamByName

Posted on 2001-07-08
2
565 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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