Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Posts
    10

    Unanswered: Using a form posted field in SELECT

    I must be either too stupid to understand that only a fixed field name can be used in SELECT, or I don't know the syntax to use with a field name supplied from a drop-down box in a form that posts to the SQL script.

    Form supplied field names work fine in WHERE, and also in SET, but not in SELECT.

    Example: 'SELECT fieldname' works of course. But when SELECT is populated from a form: 'SELECT ::form fieldname::' the field name is not recognized as a valid name.

    Is this by design? If so, I will stop trying to solve it and try other solutions.

    Thank you all.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Using a form posted field in SELECT

    Originally posted by Rosenhan
    I must be either too stupid to understand that only a fixed field name can be used in SELECT, or I don't know the syntax to use with a field name supplied from a drop-down box in a form that posts to the SQL script.

    Form supplied field names work fine in WHERE, and also in SET, but not in SELECT.

    Example: 'SELECT fieldname' works of course. But when SELECT is populated from a form: 'SELECT ::form fieldname::' the field name is not recognized as a valid name.

    Is this by design? If so, I will stop trying to solve it and try other solutions.

    Thank you all.
    Is this an Access question?

  3. #3
    Join Date
    Feb 2003
    Posts
    10
    Yes, FrontPage. See previous post 6/16/03.

  4. #4
    Join Date
    Jun 2003
    Posts
    2
    Is it not simply a case of dimming the fields in from the form ?
    Like so : e.g.

    <%

    OrderNumber = Session("Order_ID")
    Title = request.form("Title")
    Quantity = request.form("Quantity")
    Artist = request.form("Artist")
    Price = ccur(request.form("Price"))
    Stock_ID = request.form("Stock_ID")
    Total = ccur(Price) * Quantity

    %>

    <%

    sql = "INSERT INTO Cart (Order_ID, Stock_ID, Title, Artist, Quantity, Price, Total) VALUES "
    sql = sql & "('" & Ordernumber & "','" & Stock_ID & "','" & Title & "','" & Artist & "','" & Quantity &"','" & Price &"','" & Total &"')"

    conn.Execute sql
    %>

  5. #5
    Join Date
    Feb 2003
    Posts
    10
    Sorry I haven't explained the problem in a way others can understand.
    In FrontPage the databases are internal, created by FrontPage. The databases are of the Access type: *.mdb and can be read from Access just like a true Access db. In FP, all the queries are structured in the unembedded style e.g.:

    SELECT column1
    FROM table
    WHERE column2 = something

    Very simple. No embedding in ASP or PHP etc.

    When you use a form to post to a script in FP the script has to be written to accept the form fields. This is done by using the double colon syntax:

    SELECT column1
    FROM table
    WHERE ::formfieldname:: = something.

    The query knows the ::something:: syntax is a value posted to it from a form and the query would use the posted formfieldname to parse the query.

    These ::someting:: values that come from the form and post to the query work great in WHERE and SET but not in SELECT. I can't find the correct syntax, if it exists, to make this kind of query parse e.g.:

    SELECT ::formfieldname::
    FROM table
    WHERE ::formfieldname:: = something.

    FP ADODB will not recognize the posted formfield in SELECT as a valid value. It sees it as something other than the name of a column, even though a true column name was chosen in the form and posted to the query.

    I've tried SELECT "::formfield::" and SELECT ('::formfield::') and every other combination I can think of. I have researched all the knowledge bases at Microsoft and in many forums. No luck. Someone who knows the truth just needs to tell me it can't be done and I will try to develop another way to do what I neeed to do.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •