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. C#
  4. Adapter Parameter

Adapter Parameter

Scheduled Pinned Locked Moved C#
databasehelpquestion
4 Posts 3 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
    DougW48
    wrote on last edited by
    #1

    Is there a generic way of saying "everything" in a parameter of an oleDbDataAdapter? For instance, if my query asks for all rows WHERE (Name = ?), and then later in my code somewhere I have Adapter.SelectCommand.Parameters[Name].Value = "some name"; What could I put in place of "some name" that would just mean everything...or is it even possible? Also, what if Value wasn't expecting a string, what if it was a bool...what can I put to basically ignore this parameter? Thanks a bunch for any help. I tried looking it up, but I didn't know what to search for. :-D

    J H 2 Replies Last reply
    0
    • D DougW48

      Is there a generic way of saying "everything" in a parameter of an oleDbDataAdapter? For instance, if my query asks for all rows WHERE (Name = ?), and then later in my code somewhere I have Adapter.SelectCommand.Parameters[Name].Value = "some name"; What could I put in place of "some name" that would just mean everything...or is it even possible? Also, what if Value wasn't expecting a string, what if it was a bool...what can I put to basically ignore this parameter? Thanks a bunch for any help. I tried looking it up, but I didn't know what to search for. :-D

      J Offline
      J Offline
      Jon G
      wrote on last edited by
      #2

      If you leave it blank, it should use all the values in your select statement

      H 1 Reply Last reply
      0
      • D DougW48

        Is there a generic way of saying "everything" in a parameter of an oleDbDataAdapter? For instance, if my query asks for all rows WHERE (Name = ?), and then later in my code somewhere I have Adapter.SelectCommand.Parameters[Name].Value = "some name"; What could I put in place of "some name" that would just mean everything...or is it even possible? Also, what if Value wasn't expecting a string, what if it was a bool...what can I put to basically ignore this parameter? Thanks a bunch for any help. I tried looking it up, but I didn't know what to search for. :-D

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        When you use paramterized queries, you declare what type the parameter is. Value is an object so you can assign anything. Because your query uses = and not LIKE, there's nothing you can really do other than have multiple SQL commands or command strings and use whichever is appropriate if you don't want to supply a value.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • J Jon G

          If you leave it blank, it should use all the values in your select statement

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          You'll get an exception since the parameter contained no value, thus leaving a SQL statement like this to be executed:

          select * from SomeTable where Name =

          That doesn't parse correctly and therefore won't execute.

          Microsoft MVP, Visual C# My Articles

          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