DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: SQL queries

  1. #1
    Grant Guest

    SQL queries


    If I want to create an SQL query that uses a user entered variable (a field
    name in a certain table) How do I do this? I've tried making a local variable
    in this fashion
    SELECT *;
    FROM DB!TABLE;
    WHERE TABLE.variablename =

    and foxpro returns SQL: Column "VARIABLENAME" not found in DB

  2. #2
    Cindy Winegarden Guest

    Re: SQL queries

    Grant,

    Here's one way:
    lcMySelect = ;
    "SELECT * FROM Db!Table " + ;
    "WHERE Table." + cVariableName + " = ......."

    &lcMySelect

    --

    Cindy Winegarden
    Microsoft Certified Professional, Visual FoxPro

    Duke Children's Information Systems
    Duke University Medical Center

    cindyw@duke.edu



    "Grant" <Gmartin@nmbpd.com> wrote in message
    news:38fb68f2$1@news.devx.com...
    |
    | If I want to create an SQL query that uses a user entered variable
    (a field
    | name in a certain table) How do I do this? I've tried making a
    local variable
    | in this fashion
    | SELECT *;
    | FROM DB!TABLE;
    | WHERE TABLE.variablename =
    |
    | and foxpro returns SQL: Column "VARIABLENAME" not found in DB



  3. #3
    Anders Altberg Guest

    Re: SQL queries

    cVariablename="lastname"
    cTable = 'People.dbf'
    cFilter

    SELECT * FROM (cTable) AS T WHERE T.&cVariablename = ?cFilter

    -Anders

    "Grant" <Gmartin@nmbpd.com> wrote in message
    news:38fb68f2$1@news.devx.com...
    >
    > If I want to create an SQL query that uses a user entered variable (a

    field
    > name in a certain table) How do I do this? I've tried making a local

    variable
    > in this fashion
    > SELECT *;
    > FROM DB!TABLE;
    > WHERE TABLE.variablename =
    >
    > and foxpro returns SQL: Column "VARIABLENAME" not found in DB




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links