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. General Programming
  3. Visual Basic
  4. Parameters with SQL IN operator

Parameters with SQL IN operator

Scheduled Pinned Locked Moved Visual Basic
databasetutorial
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.
  • D Offline
    D Offline
    danasegaranea
    wrote on last edited by
    #1

    Hi all, How can use the IN Operator with Parameters. Any Example will be helpfull Thanks Dana

    A 1 Reply Last reply
    0
    • D danasegaranea

      Hi all, How can use the IN Operator with Parameters. Any Example will be helpfull Thanks Dana

      A Offline
      A Offline
      Arjun Marwaha
      wrote on last edited by
      #2

      Hello Dana, The values that do not fit into a neat range, we use the IN operator. An example would be: Select * from Customers Where CustID IN (1, 3, 5); The above query will give us rows for CustID 1, 3 and 5 from the Customer's table. Regards, Dave

      Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com

      D 1 Reply Last reply
      0
      • A Arjun Marwaha

        Hello Dana, The values that do not fit into a neat range, we use the IN operator. An example would be: Select * from Customers Where CustID IN (1, 3, 5); The above query will give us rows for CustID 1, 3 and 5 from the Customer's table. Regards, Dave

        Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com

        D Offline
        D Offline
        danasegaranea
        wrote on last edited by
        #3

        Thanks for the post Dave Traister, How can I implement this using Sqlcomamnd.Parameters object Regards, Dana

        A 1 Reply Last reply
        0
        • D danasegaranea

          Thanks for the post Dave Traister, How can I implement this using Sqlcomamnd.Parameters object Regards, Dana

          A Offline
          A Offline
          Arjun Marwaha
          wrote on last edited by
          #4

          Hello Dana, Try the following: Dim commandText As String = _ "Select * from Customers Where CustID IN ( @ID);" command.Parameters.Add("@ID", SqlDbType.Int) command.Parameters("@ID").Value = customerID Dim rowsAffected As Integer = command.ExecuteNonQuery() The link below shall give you more information but it does not use the IN operator: http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx Regards, Dave

          Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com

          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