Solved

ParamByName

Posted on 2001-07-08
2
558 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
Comment Utility
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:
mnasman earned 50 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now