Adapter Parameter
-
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
-
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
-
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
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 notLIKE
, 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
-
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