SQL variable

Results 1 to 4 of 4

Thread: SQL variable

  1. #1
    Join Date
    Dec 1969

    Default SQL variable

    I don&#039;t know if this is the right place to post this or not..but..<BR>I need to pass a variable into a SQL Select statement from a submitted page. I have the submit to and request.form set up... now I just need to know how to incorporate the passed value into the Select statement. Select * from table1 WHERE field1 = ??<BR>I am new at this, and to make it more difficult, I am using Microsoft Visual Interdev and DTC&#039;s instead of normal connections and sql statements.<BR>

  2. #2
    Join Date
    Dec 1969

    Default You just need to add it to the end of the string..

    Here is an example if the field is of type:text<BR><BR>SQL = "Select * from table1 where field1=&#039;" & request("field1") & "&#039;"<BR><BR>Note the &#039; in the select statement. SQL needs these to identify the field as a text or string type...<BR><BR>Here is a number field.<BR><BR>SQL = "Select * from table1 where field1=" & request("field1")<BR><BR>Notice that there are no &#039; characaters...<BR><BR>Happy programming...<BR><BR>-- Whol

  3. #3
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Dont really get it....

    if the value available in your Request object in the page you submitted TO??<BR><BR>if it is then<BR><BR>....where field1 = " & TheVariable<BR><BR>if it is a string<BR><BR>....where field1 = &#039;" & TheVariable & "&#039;"<BR><BR>wat this it??<BR>

  4. #4
    Dave Greene Guest

    Default RE: Dont really get it....

    The key to this example is that you are NOT passing your variable to the back-end. You are passing the VALUE of the variable because the back-end has no other way to know the value of the front-end variable. <BR><BR>Remember, the text you are passing to the back end is a SQL statement, formatted as a text string. Think of it as passing instructions. The back-end then evaluates those instructions to produce a result set for you, hence no quotes for numeric values and quotes for text values. <BR><BR>

Posting Permissions

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