Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ParamByName

Posted on 2001-07-08
2
Medium Priority
?
579 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 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

Technology Partners: 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

824 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