Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SELECT WITH VARIABLE

SELECT WITH VARIABLE

Scheduled Pinned Locked Moved Web Development
questiondatabase
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    evlxtc
    wrote on last edited by
    #1

    I have a variable called "testvar" with a value of (let's say)OPT My SQL SELECT statement I have this "SELECT FROM PRICELIST WHERE CAT =" &TESTVAR Or something like this. IF I change the testvar in the select to "OPT" it works but not if just OPT.. How do I get my TESTVAR sert to hav the guotes in allready. ????? I KNOW it must be something silly? PLEASE? I assign the testvar="OPT" but need the select statement to then add this corectly to do a = to OPT? HOPE this is enough info. (P.S. yes I am a newby as you can see :) evlxtc

    G 1 Reply Last reply
    0
    • E evlxtc

      I have a variable called "testvar" with a value of (let's say)OPT My SQL SELECT statement I have this "SELECT FROM PRICELIST WHERE CAT =" &TESTVAR Or something like this. IF I change the testvar in the select to "OPT" it works but not if just OPT.. How do I get my TESTVAR sert to hav the guotes in allready. ????? I KNOW it must be something silly? PLEASE? I assign the testvar="OPT" but need the select statement to then add this corectly to do a = to OPT? HOPE this is enough info. (P.S. yes I am a newby as you can see :) evlxtc

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You have to put apostrophes around the string value: "SELECT FROM PRICELIST WHERE CAT = '" & TESTVAR & "'" This will give you a string that contains: SELECT FROM PRICELIST WHERE CAT = 'OPT' --- b { font-weight: normal; }

      E 1 Reply Last reply
      0
      • G Guffa

        You have to put apostrophes around the string value: "SELECT FROM PRICELIST WHERE CAT = '" & TESTVAR & "'" This will give you a string that contains: SELECT FROM PRICELIST WHERE CAT = 'OPT' --- b { font-weight: normal; }

        E Offline
        E Offline
        evlxtc
        wrote on last edited by
        #3

        Thanks, that is all I needed. :)NOW I just need to finish a few small graphics and that will be that for this site. :) PS How do I in anycase concat a string to make a variable = "something" or is this not possible straight forward? this is me

        G 1 Reply Last reply
        0
        • E evlxtc

          Thanks, that is all I needed. :)NOW I just need to finish a few small graphics and that will be that for this site. :) PS How do I in anycase concat a string to make a variable = "something" or is this not possible straight forward? this is me

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Do you mean that you want the apostrophes to be added to the beginning and end of a string? variable = string.Concat("'", variable, "'"); or variable = "'" + variable + "'"; or variable = string.Format("'{0}'", variable); --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups